fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
e4dcf6b386220918d8a355e951a2d7e8a73e5a6dTony Nguyen * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fct_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fct_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fct_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fct_open(dev_t *devp, int flag, int otype, cred_t *credp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fct_close(dev_t dev, int flag, int otype, cred_t *credp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fct_ioctl(dev_t dev, int cmd, intptr_t data, int mode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* streamtab */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t rportid_table_size = FCT_HASH_TABLE_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int max_cached_ncmds = FCT_MAX_CACHED_CMDS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&fct_global_mutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *result = (void *)(uintptr_t)ddi_get_instance(fct_dip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_create_minor_node(dip, "admin", S_IFCHR, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_open(dev_t *devp, int flag, int otype, cred_t *credp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_close(dev_t dev, int flag, int otype, cred_t *credp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_ioctl(dev_t dev, int cmd, intptr_t data, int mode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_copyin_iocdata(intptr_t data, int mode, fctio_t **fctio,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *fctio = kmem_zalloc(sizeof (fctio_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)data, *fctio, sizeof (fctio_t), mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ibuf = kmem_zalloc((*fctio)->fctio_ilen, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)(unsigned long)(*fctio)->fctio_ibuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *abuf = kmem_zalloc((*fctio)->fctio_alen, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((void *)(unsigned long)(*fctio)->fctio_abuf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *obuf = kmem_zalloc((*fctio)->fctio_olen, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_copyout_iocdata(intptr_t data, int mode, fctio_t *fctio, void *obuf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(unsigned long)fctio->fctio_obuf, fctio->fctio_olen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ddi_copyout(fctio, (void *)data, sizeof (fctio_t), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (iport = fct_iport_list; iport; iport = iport->iport_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* invoked with fct_global_mutex locked */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (iport = fct_iport_list; iport; iport = iport->iport_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(iport->iport_port->port_pwwn, pwwn, 8) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_get_adapter_attr(uint8_t *pwwn, fc_tgt_hba_adapter_attributes_t *hba_attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba_attr->version = FCT_HBA_ADAPTER_ATTRIBUTES_VERSION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = (fct_port_attrs_t *)kmem_zalloc(sizeof (fct_port_attrs_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_port->port_populate_hba_details(iport->iport_port, attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(attr->manufacturer, hba_attr->Manufacturer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(attr->serial_number, hba_attr->SerialNumber,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(attr->model, hba_attr->Model, sizeof (hba_attr->Model));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(attr->model_description, hba_attr->ModelDescription,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(utsname.nodename, hba_attr->NodeSymbolicName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(attr->hardware_version, hba_attr->HardwareVersion,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(attr->option_rom_version, hba_attr->OptionROMVersion,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(attr->firmware_version, hba_attr->FirmwareVersion,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba_attr->VendorSpecificID = attr->vendor_specific_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(iport->iport_port->port_nwwn, hba_attr->NodeWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(attr->driver_version, hba_attr->DriverVersion,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hba_attr->NumberOfPorts = fct_count_fru_ports(iport); */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_get_adapter_port_attr(fct_i_local_port_t *ilport, uint8_t *pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_tgt_hba_port_attributes_t *port_attr, uint32_t *err_detail)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->version = FCT_HBA_PORT_ATTRIBUTES_VERSION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = (fct_port_attrs_t *)kmem_zalloc(sizeof (fct_port_attrs_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_port->port_populate_hba_details(iport->iport_port, attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->lastChange = iport->iport_last_change;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(iport->iport_port->port_nwwn, port_attr->NodeWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(iport->iport_port->port_pwwn, port_attr->PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(port_attr->FabricName, sizeof (port_attr->FabricName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortFcId = iport->iport_link_info.portid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortSupportedClassofService = attr->supported_cos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the definition is different so need to translate */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortSupportedSpeed |= FC_HBA_PORTSPEED_1GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortSupportedSpeed |= FC_HBA_PORTSPEED_2GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortSupportedSpeed |= FC_HBA_PORTSPEED_4GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortSupportedSpeed |= FC_HBA_PORTSPEED_8GBIT;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port_attr->PortSupportedSpeed |= FC_HBA_PORTSPEED_10GBIT;
e4dcf6b386220918d8a355e951a2d7e8a73e5a6dTony Nguyen port_attr->PortSupportedSpeed |= FC_HBA_PORTSPEED_16GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortMaxFrameSize = attr->max_frame_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->NumberofDiscoveredPorts = iport->iport_nrps_login;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; i < iport->iport_port->port_max_logins; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_get_discovered_port_attr(fct_i_remote_port_t *remote_port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *port_wwn, uint32_t index, fc_tgt_hba_port_attributes_t *port_attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->version = FCT_HBA_PORT_ATTRIBUTES_VERSION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; i < iport->iport_port->port_max_logins; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->lastChange = iport->iport_last_change;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(port_attr->PortSymbolicName, irp->irp_spn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortSupportedClassofService = irp->irp_cos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)irp->irp_fc4types, port_attr->PortActiveFc4Types,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((caddr_t)irp->irp_fc4types, port_attr->PortSupportedFc4Types,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr->PortSupportedSpeed = FC_HBA_PORTSPEED_UNKNOWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_tgt_hba_port_attributes_t *port_attr, uint32_t *error_detail)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fct_get_adapter_port_attr(iport, port_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (iport = fct_iport_list; iport; iport = iport->iport_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rportid_table_size; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_tgt_hba_adapter_port_stats_t *port_stats, uint32_t *error_detail)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_local_port_t *iport = fct_get_iport_per_wwn(port_wwn);
c946faca5d4627284fb79c6b04e652b471034495allan uint32_t buf_size = sizeof (fc_tgt_hba_adapter_port_stats_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_stats->version = FCT_HBA_ADAPTER_PORT_STATS_VERSION;
c946faca5d4627284fb79c6b04e652b471034495allan iport->iport_port, NULL, (uint8_t *)&stat, &buf_size);
c946faca5d4627284fb79c6b04e652b471034495allan port_stats->LossOfSignalCount = stat.LossOfSignalsCount;
c946faca5d4627284fb79c6b04e652b471034495allanfct_get_link_status(uint8_t *port_wwn, uint64_t *dest_id,
c946faca5d4627284fb79c6b04e652b471034495allan fct_port_link_status_t *link_status, uint32_t *error_detail)
c946faca5d4627284fb79c6b04e652b471034495allan fct_i_local_port_t *iport = fct_get_iport_per_wwn(port_wwn);
c946faca5d4627284fb79c6b04e652b471034495allan * If what we are requesting is zero or same as local port,
c946faca5d4627284fb79c6b04e652b471034495allan * then we use port_info()
c946faca5d4627284fb79c6b04e652b471034495allan if (dest_id == NULL || *dest_id == iport->iport_link_info.portid) {
c946faca5d4627284fb79c6b04e652b471034495allan return (0);
c946faca5d4627284fb79c6b04e652b471034495allan * For remote port, we will send RLS
c946faca5d4627284fb79c6b04e652b471034495allan for (i = 0; i < rportid_table_size; i++) {
c946faca5d4627284fb79c6b04e652b471034495allan iport->iport_rls_cb_data.fct_link_status = link_status;
c946faca5d4627284fb79c6b04e652b471034495allan CMD_TO_ICMD(cmd)->icmd_cb_private = &iport->iport_rls_cb_data;
c946faca5d4627284fb79c6b04e652b471034495allan if (iport->iport_rls_cb_data.fct_els_res != FCT_SUCCESS)
a79493184c9332129c9c91500069322f6f3fafddReed return (-1);
a79493184c9332129c9c91500069322f6f3fafddReed return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = fct_copyin_iocdata(data, mode, &fctio, &ibuf, &abuf, &obuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_tgt_hba_list_t *list = (fc_tgt_hba_list_t *)obuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fctio->fctio_olen < sizeof (fc_tgt_hba_list_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = fct_get_port_list((char *)list->port_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_length = sizeof (fc_tgt_hba_adapter_attributes_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba_attr = (fc_tgt_hba_adapter_attributes_t *)obuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_length = sizeof (fc_tgt_hba_port_attributes_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr = (fc_tgt_hba_port_attributes_t *)obuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = fct_get_adapter_port_attr(NULL, port_wwn, port_attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_length = sizeof (fc_tgt_hba_port_attributes_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr = (fc_tgt_hba_port_attributes_t *)obuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = fct_get_discovered_port_attr(NULL, port_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_length = sizeof (fc_tgt_hba_port_attributes_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_attr = (fc_tgt_hba_port_attributes_t *)obuf;
c946faca5d4627284fb79c6b04e652b471034495allan ret = fct_get_link_status(port_wwn, dest_id, link_status,
a79493184c9332129c9c91500069322f6f3fafddReed ret = fct_forcelip((uint8_t *)ibuf, &fctio->fctio_errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = fct_copyout_iocdata(data, mode, fctio, obuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fct_copyout_iocdata(data, mode, fctio, obuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *bp; /* back pointer from internal struct to main struct */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GET_STRUCT_SIZE(fct_i_cmd_t), GET_STRUCT_SIZE(fct_els_t) },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GET_STRUCT_SIZE(fct_i_cmd_t), GET_STRUCT_SIZE(fct_els_t) },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GET_STRUCT_SIZE(fct_i_cmd_t), GET_STRUCT_SIZE(fct_sol_ct_t) },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { GET_STRUCT_SIZE(fct_cmd_t), GET_STRUCT_SIZE(fct_i_cmd_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { GET_STRUCT_SIZE(fct_cmd_t), /* FCT_STRUCT_CMD_FCP_XCHG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_alloc(fct_struct_id_t struct_id, int additional_size, int flags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((struct_id == 0) || (struct_id >= FCT_MAX_STRUCT_IDS))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((curthread->t_flag & T_INTR_THREAD) || (flags & AF_FORCE_NOSLEEP)) {
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer fct_sizes[struct_id].struct_specific + additional_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ds = (stmf_dbuf_store_t *)stmf_alloc(STMF_STRUCT_DBUF_STORE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sh = (__fct_t *)kmem_zalloc(fct_size, kmem_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sh->fp = (__ifct_t *)GET_BYTE_OFFSET(sh, fct_sizes[struct_id].shared);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sh->cp = GET_BYTE_OFFSET(sh->fp, fct_sizes[struct_id].fw_private);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sh->ss = GET_BYTE_OFFSET(sh->cp, additional_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (struct_id == FCT_STRUCT_CMD_RCVD_ELS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (struct_id == FCT_STRUCT_CMD_SOL_ELS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (struct_id == FCT_STRUCT_CMD_RCVD_ABTS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(ct->ct_req_payload, ct->ct_req_alloc_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(ct->ct_resp_payload, ct->ct_resp_alloc_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((struct_id == FCT_STRUCT_CMD_RCVD_ELS) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_free(((fct_local_port_t *)ptr)->port_lport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_alloc_dbuf(scsi_task_t *task, uint32_t size, uint32_t *pminsize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (port->port_fds->fds_alloc_data_buf(port, size,
3fb517f786391b507780c78aabb8d98bfea9efe9James Moorefct_setup_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf, uint32_t flags)
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore return (port->port_fds->fds_setup_dbuf(port, dbuf, flags));
3fb517f786391b507780c78aabb8d98bfea9efe9James Moorefct_teardown_dbuf(stmf_dbuf_store_t *ds, stmf_data_buf_t *dbuf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_free_dbuf(stmf_dbuf_store_t *ds, stmf_data_buf_t *dbuf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport = (fct_i_local_port_t *)port->port_fct_private;
162fafd3d0764eb6022fe01ce970de8775eda209allan "fct: %s driver version mismatch",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l < 16) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(iport->iport_alias, port->port_default_alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_wwn_to_devid_desc((scsi_devid_desc_t *)iport->iport_id,
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan (void) snprintf(taskq_name, sizeof (taskq_name), "stmf_fct_taskq_%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((iport->iport_worker_taskq = ddi_taskq_create(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&iport->iport_worker_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_init(&iport->iport_worker_cv, NULL, CV_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_init(&iport->iport_lock, NULL, RW_DRIVER, NULL);
c946faca5d4627284fb79c6b04e652b471034495allan sema_init(&iport->iport_rls_sema, 0, NULL, SEMA_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remote port mgmt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_rp_slots = (fct_i_remote_port_t **)kmem_zalloc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->port_max_logins * sizeof (fct_i_remote_port_t *), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_rp_tb = kmem_zalloc(rportid_table_size *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fct_cmds for SCSI traffic */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&iport->iport_cached_cmd_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize cmd slots */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_cmd_slots = (fct_cmd_slot_t *)kmem_zalloc(
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer port->port_max_xchges * sizeof (fct_cmd_slot_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_nslots_free = port->port_max_xchges;
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (port->port_max_xchges * FCT_TASK_GREEN_LIMIT) / 100;
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (port->port_max_xchges * FCT_TASK_YELLOW_LIMIT) / 100;
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (port->port_max_xchges * FCT_TASK_RED_LIMIT) / 100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Start worker thread */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_and_32(&iport->iport_flags, ~IPORT_TERMINATE_WORKER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_taskq_dispatch(iport->iport_worker_taskq,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for taskq to start */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((iport->iport_flags & IPORT_WORKER_RUNNING) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lport->lport_id = (scsi_devid_desc_t *)iport->iport_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->port_fds->fds_ds->ds_alloc_data_buf = fct_alloc_dbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->port_fds->fds_ds->ds_free_data_buf = fct_free_dbuf;
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore port->port_fds->fds_ds->ds_setup_dbuf = fct_setup_dbuf;
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore port->port_fds->fds_ds->ds_teardown_dbuf = fct_teardown_dbuf;
cd36db67f9470c74ed7f5bbd57ec6eeb84f71fcdJohn Forte /* set up as alua participating port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stmf_register_local_port(port->port_lport) != FCT_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) stmf_lport_add_event(lport, LPORT_EVENT_INITIAL_LUN_MAPPED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_log_local_port_event(port, ESC_SUNFC_PORT_ATTACH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Stop the taskq 1st */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&iport->iport_flags, IPORT_TERMINATE_WORKER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iport->iport_flags & IPORT_WORKER_RUNNING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(iport->iport_rp_tb, rportid_table_size *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport = (fct_i_local_port_t *)port->port_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Stop the taskq 1st */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&iport->iport_flags, IPORT_TERMINATE_WORKER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stmf_deregister_local_port(port->port_lport) != FCT_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_next->iport_prev = iport->iport_prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_prev->iport_next = iport->iport_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * At this time, there should be no outstanding and pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I/Os, so we can just release resources.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(iport->iport_total_alloced_ncmds == iport->iport_cached_ncmds);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (icmd = iport->iport_cached_cmdlist; icmd; icmd = next_icmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(iport->iport_cmd_slots, port->port_max_xchges *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(iport->iport_rp_slots, port->port_max_logins *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(iport->iport_rp_tb, rportid_table_size *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_log_local_port_event(port, ESC_SUNFC_PORT_DETACH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Restart the worker */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_and_32(&iport->iport_flags, ~IPORT_TERMINATE_WORKER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_taskq_dispatch(iport->iport_worker_taskq,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for taskq to start */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((iport->iport_flags & IPORT_WORKER_RUNNING) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_handle_event(fct_local_port_t *port, int event_id, uint32_t event_flags,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_local_port_t *iport = (fct_i_local_port_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte e = kmem_zalloc(sizeof (fct_i_event_t), KM_NOSLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * XXX Throw HBA fatal error event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_handle_event: iport-%p, allocation "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_RFLAG_FATAL_ERROR | STMF_RFLAG_RESET, info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Just queue the event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_event_head = iport->iport_event_tail = e;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called with iport_lock held as reader.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_portid_to_portptr(fct_i_local_port_t *iport, uint32_t portid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte irp = iport->iport_rp_tb[FCT_PORTID_HASH_FUNC(portid)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called with irp_lock held as writer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_queue_rp(fct_i_local_port_t *iport, fct_i_remote_port_t *irp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called with irp_lock and iport_lock held as writer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_deque_rp(fct_i_local_port_t *iport, fct_i_remote_port_t *irp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_is_irp_logging_out(fct_i_remote_port_t *irp, int force_implicit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((irp->irp_flags & IRP_IN_DISCOVERY_QUEUE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((irp->irp_els_list == NULL) && (irp->irp_deregister_timer)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (force_implicit && irp->irp_nonfcp_xchg_count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Last session affecting ELS should be a LOGO */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (icmd = irp->irp_els_list; icmd; icmd = icmd->icmd_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t op = (ICMD_TO_ELS(icmd))->els_req_payload[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The force_implicit flag enforces the implicit semantics which may be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * needed if a received logout got stuck e.g. a response to a received
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * LOGO never came back from the FCA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_implicitly_logo_all(fct_i_local_port_t *iport, int force_implicit)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rportid_table_size; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = fct_create_solels(iport->iport_port, irp->irp_rp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_implictly_logo_all: cmd null");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport_rp_tb_new = kmem_zalloc(rportid_table_size *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reconstruct the hash table */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rportid_table_size; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_local_port_cleanup_done(fct_i_local_port_t *iport)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* loop all rps to check if the cmd have already been drained */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rportid_table_size; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_scsi_task_alloc(fct_local_port_t *port, uint16_t rp_handle,
e4dcf6b386220918d8a355e951a2d7e8a73e5a6dTony Nguyen uint32_t rportid, uint8_t *lun, uint16_t cdb_length, uint16_t task_ext)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((iport->iport_link_state & S_LINK_ONLINE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(iport->iport_alias, "cmd alloc called while the port"
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer " was offline");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(iport->iport_alias, "cmd received from "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((irp = iport->iport_rp_slots[rp_handle]) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(iport->iport_alias, "cmd received from "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(iport->iport_alias, "cmd alloc called while fcp "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "login was not done. portid=%x, rp=%p", rp->rp_id, rp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((icmd = iport->iport_cached_cmdlist) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = (fct_cmd_t *)fct_alloc(FCT_STRUCT_CMD_FCP_XCHG,
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_inc_32(&iport->iport_total_alloced_ncmds);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The accuracy of iport_max_active_ncmds is not important
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((iport->iport_total_alloced_ncmds - iport->iport_cached_ncmds) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Lets get a slot */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(iport->iport_alias, "Ran out of xchg resources");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmd->icmd_flags |= ICMD_IN_TRANSITION | ICMD_KNOWN_TO_FCA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->cmd_specific = stmf_task_alloc(port->port_lport, irp->irp_session,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((task = (scsi_task_t *)cmd->cmd_specific) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_cmd_t *cmd = (fct_cmd_t *)task->task_port_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->cmd_comp_status = task->task_completion_status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_post_rcvd_cmd(fct_cmd_t *cmd, stmf_data_buf_t *dbuf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (fct_i_local_port_t *)cmd->cmd_port->port_fct_private;
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (fct_i_remote_port_t *)cmd->cmd_rp->rp_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_task_t *task = (scsi_task_t *)cmd->cmd_specific;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t load = iport->iport_total_alloced_ncmds -
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore * If the target driver accepts sglists, fill in task fields.
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore task->task_additional_flags |= TASK_AF_ACCEPT_LU_DBUF;
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore task->task_copy_threshold = fds->fds_copy_threshold;
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore task->task_max_xfer_len = fds->fds_max_sgl_xfer_len;
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore * A single stream load encounters a little extra
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore * latency if large xfers are done in 1 chunk.
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore * Give a hint to the LU that starting the xfer
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore * with a smaller chunk would be better in this case.
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore * For any other load, use maximum chunk size.
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore /* estimate */
3fb517f786391b507780c78aabb8d98bfea9efe9James Moore /* zero means no hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_post_task((scsi_task_t *)cmd->cmd_specific, dbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_and_32(&icmd->icmd_flags, ~ICMD_IN_TRANSITION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We dont need dbuf for other cmds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function bypasses fct_handle_els()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_remote_port_t *irp = (fct_i_remote_port_t *)rp->rp_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&icmd->icmd_flags, ICMD_IMPLICIT_CMD_HAS_RESOURCE);
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_inc_16(&irp->irp_nonfcp_xchg_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * An implicit LOGO can also be posted to a irp where a PLOGI might
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be in process. That PLOGI will reset this flag and decrement the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iport_nrps_login counter.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_and_32(&irp->irp_flags, ~(IRP_PLOGI_DONE | IRP_PRLI_DONE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&icmd->icmd_flags, ICMD_SESSION_AFFECTING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * called with iport_lock held, return the slot number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_alloc_cmd_slot(fct_i_local_port_t *iport, fct_cmd_t *cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We use high order 16 bits as a counter which keeps on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * incrementing to avoid ABA issues with atomic lists.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new |= iport->iport_cmd_slots[cmd_slot].slot_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (atomic_cas_32(&iport->iport_next_free_slot, old, new) != old);
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_dec_16(&iport->iport_nslots_free);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_cmd_slots[cmd_slot].slot_cmd = icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->cmd_handle = (uint32_t)cmd_slot | 0x80000000 |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((uint32_t)(iport->iport_cmd_slots[cmd_slot].slot_uniq_cntr))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If icmd is not NULL, irp_lock must be held
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_post_to_discovery_queue(fct_i_local_port_t *iport,
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer p = &((*p)->icmd_next))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&icmd->icmd_flags, ICMD_IN_IRP_QUEUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((irp->irp_flags & IRP_IN_DISCOVERY_QUEUE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CAUTION: do not grab local_port/remote_port locks after
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * grabbing the worker lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_rpwe_tail->irp_discovery_next = irp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_rpwe_head = iport->iport_rpwe_tail = irp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&irp->irp_flags, IRP_IN_DISCOVERY_QUEUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need always signal the port worker irrespective of the fact that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * irp is already in discovery queue or not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_xfer_scsi_data(scsi_task_t *task, stmf_data_buf_t *dbuf, uint32_t ioflags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_cmd_t *cmd = (fct_cmd_t *)task->task_port_private;
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer fct_i_local_port_t, cmd->cmd_port->port_fct_private,
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer fct_i_remote_port_t, cmd->cmd_rp->rp_fct_private,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cmd->cmd_port->port_xfer_scsi_data(cmd, dbuf, ioflags));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_scsi_data_xfer_done(fct_cmd_t *cmd, stmf_data_buf_t *dbuf, uint32_t ioflags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer fct_i_local_port_t, cmd->cmd_port->port_fct_private,
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer fct_i_remote_port_t, cmd->cmd_rp->rp_fct_private,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (atomic_cas_32(&icmd->icmd_flags, old, new) != old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_data_xfer_done((scsi_task_t *)cmd->cmd_specific, dbuf, iof);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_send_scsi_status(scsi_task_t *task, uint32_t ioflags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_cmd_t *cmd = (fct_cmd_t *)task->task_port_private;
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (fct_i_local_port_t *)cmd->cmd_port->port_fct_private,
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (fct_i_remote_port_t *)cmd->cmd_rp->rp_fct_private);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cmd->cmd_port->port_send_cmd_response(cmd, ioflags));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_send_response_done(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_local_port_t *iport = (fct_i_local_port_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Until we support confirmed completions, this is an error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (atomic_cas_32(&icmd->icmd_flags, old, new) != old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_send_status_done((scsi_task_t *)cmd->cmd_specific, s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Tell the caller that we are done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&icmd->icmd_flags, ICMD_CMD_COMPLETE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_local_port_t *iport = (fct_i_local_port_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Give the slot back */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t n = CMD_HANDLE_SLOT_INDEX(cmd->cmd_handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If anything went wrong, grab the lock as writer. This is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * probably unnecessary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX Validate slot before freeing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (atomic_cas_32(&iport->iport_next_free_slot,
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_inc_16(&iport->iport_nslots_free);
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_dec_16(&irp->irp_nonfcp_xchg_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (icmd->icmd_flags & ICMD_IMPLICIT_CMD_HAS_RESOURCE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* for implicit cmd, no cmd slot is used */
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_dec_16(&irp->irp_nonfcp_xchg_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * XXX Throw HBA fatal error event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Later shutdown svc will terminate the ABTS in the end
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_cmd_free: iport-%p, ABTS_ACC"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " port_send_cmd_response failed", (void *)iport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_RFLAG_FATAL_ERROR | STMF_RFLAG_RESET, info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the cmd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iport->iport_cached_ncmds < max_cached_ncmds) {
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek atomic_dec_32(&iport->iport_total_alloced_ncmds);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_scsi_abort(stmf_local_port_t *lport, int abort_cmd, void *arg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = (fct_local_port_t *)lport->lport_port_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new |= ICMD_BEING_ABORTED | ICMD_FCA_ABORT_CALLED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (atomic_cas_32(&icmd->icmd_flags, old, new) != old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret == FCT_NOT_FOUND) || (ret == FCT_ABORT_SUCCESS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_and_32(&icmd->icmd_flags, ~ICMD_KNOWN_TO_FCA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_and_32(&icmd->icmd_flags, ~ICMD_FCA_ABORT_CALLED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_ctl(struct stmf_local_port *lport, int cmd, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = (fct_local_port_t *)lport->lport_port_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport = (fct_i_local_port_t *)port->port_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We are mostly a passthrough, except during offline.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (iport->iport_state != FCT_STATE_OFFLINE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) stmf_ctl(STMF_CMD_LPORT_ONLINE_COMPLETE, lport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(iport->iport_state == FCT_STATE_ONLINING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) stmf_ctl(STMF_CMD_LPORT_ONLINE_COMPLETE, lport, arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->port_ctl(port, FCT_ACK_PORT_ONLINE_COMPLETE, arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) stmf_ctl(STMF_CMD_LPORT_OFFLINE_COMPLETE, lport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(iport->iport_state == FCT_STATE_OFFLINING);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) stmf_ctl(STMF_CMD_LPORT_OFFLINE_COMPLETE, lport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If FCA's offline was successful, we dont tell stmf yet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Becasue now we have to do the cleanup before we go upto
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmf. That cleanup is done by the worker thread.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FCA is offline, post a link down, its harmless anyway */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_handle_event(port, FCT_EVENT_LINK_DOWN, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Trigger port offline processing by the worker */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->port_ctl(port, FCT_ACK_PORT_OFFLINE_COMPLETE, arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_info(uint32_t cmd, stmf_local_port_t *lport, void *arg, uint8_t *buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * implicit: if it's true, it means it will only be used in fct module, or else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it will be sent to the link.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_create_solels(fct_local_port_t *port, fct_remote_port_t *rp, int implicit,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t elsop, uint32_t wkdid, fct_icmd_cb_t icmdcb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = (fct_cmd_t *)fct_alloc(FCT_STRUCT_CMD_SOL_ELS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (((irp = fct_portid_to_portptr(PORT_TO_IPORT(port),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_create_solels: Must PLOGI to %x first", wkdid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->cmd_lportid = (PORT_TO_IPORT(port))->iport_link_info.portid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since we will not send it to FCA, so we only allocate space
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Handling implicit LOGO should dependent on as less
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as resources. So a trick here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->els_req_alloc_size = els->els_req_size = 116;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->els_resp_alloc_size = els->els_resp_size = 116;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate space for its request and response
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Fill the request payload according to spec.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->els_resp_alloc_size = els->els_resp_size = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->els_req_alloc_size = els->els_req_size = 16;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptid = PORT_TO_IPORT(port)->iport_link_info.portid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_value_to_netbuf(ptid, els->els_req_payload + 5, 3);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(port->port_pwwn, els->els_req_payload + 8, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->els_resp_alloc_size = els->els_resp_size = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptid = PORT_TO_IPORT(port)->iport_link_info.portid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_value_to_netbuf(ptid, els->els_req_payload + 5, 3);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->els_resp_alloc_size = els->els_resp_size = 116;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->els_req_alloc_size = els->els_req_size = 116;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common service parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* CI0: Continuously Increasing Offset - 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* RRO: Randomly Relative Offset - 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* VVV: Vendor Version Level - 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* N-F: N or F Port Payload Sender - 0 (N) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* BBM: BB Credit Management - 0 (Normal) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Max RX size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NPTCS: N Port Total Concurrent Sequences - 0x0000 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ROIC: Relative Offset By Info - 0xFFFF */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* EDTOV: Error Detect Timeout - 0x000007D0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Class-3 Parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-VAL: Class 3 Value - 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-XID: X_ID Reassignment - 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-IPA: Initial Process Assignment */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-AI-DCC: Data compression capable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-AI-DC-HB: Data compression history buffer size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-AI-DCE: Data encrytion capable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-AI-CSC: Clock synchronization capable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-ErrPol: Error pliciy */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-CatSeq: Information Cat. Per Sequence */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-AR-DCC: */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-AR-DC-HB: */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-AR-DCE: */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-AR-CSC */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-RxSize: Class 3 receive data size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-ConSeq: Class 3 Concourrent sequences */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* C3-OSPE: Class 3 open sequence per exchange */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte els->els_resp_alloc_size = els->els_resp_size = 4;
c946faca5d4627284fb79c6b04e652b471034495allan fct_value_to_netbuf(ptid, els->els_req_payload + 5, 3);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_create_solct(fct_local_port_t *port, fct_remote_port_t *query_rp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate space
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We should have PLOGIed to the name server (0xFFFFFC)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Caution: this irp is not query_rp->rp_fct_private.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte irp = fct_portid_to_portptr((fct_i_local_port_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_create_solct: Must PLOGI name server first");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->cmd_lportid = (PORT_TO_IPORT(port))->iport_link_info.portid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate max space for its sybolic name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Port Identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[17] = (iport->iport_link_info.portid >> 16) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[18] = (iport->iport_link_info.portid >> 8) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[19] = (iport->iport_link_info.portid >> 0) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Port Identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[17] = (iport->iport_link_info.portid >> 16) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[18] = (iport->iport_link_info.portid >> 8) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[19] = (iport->iport_link_info.portid >> 0) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Class of Service
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Port Identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[17] = (iport->iport_link_info.portid >> 16) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[18] = (iport->iport_link_info.portid >> 8) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[19] = (iport->iport_link_info.portid >> 0) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC-4 Protocol Types
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we get here, port->port_sym_port_name is always not NULL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Port Identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[17] = (iport->iport_link_info.portid >> 16) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[18] = (iport->iport_link_info.portid >> 8) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[19] = (iport->iport_link_info.portid >> 0) & 0xFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * String length
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Symbolic port name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(port->port_sym_port_name, p + 21, ct->ct_req_size - 21);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * String length
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Symbolic node name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Port Identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Port Identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Port Identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct->ct_resp_payload = (uint8_t *)kmem_zalloc(ct->ct_resp_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ct->ct_req_payload = (uint8_t *)kmem_zalloc(ct->ct_req_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* CONSTCOND */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cmd can only be solicited CT/ELS. They will be dispatched to the discovery
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * queue eventually too.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We queue solicited cmds here to track solicited cmds and to take full use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of single thread mechanism.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * But in current implmentation, we don't use this mechanism on SOL_CT, PLOGI.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To avoid to interrupt current flow, ICMD_IN_SOLCMD_QUEUE is used here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_post_to_solcmd_queue(fct_local_port_t *port, fct_cmd_t *cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_local_port_t *iport = (fct_i_local_port_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmd->icmd_solcmd_next = iport->iport_solcmd_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&icmd->icmd_flags, ICMD_IN_SOLCMD_QUEUE | ICMD_SOLCMD_NEW);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_event_handler(stmf_local_port_t *lport, int eventid, void *arg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_local_port_t *iport = (fct_i_local_port_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte irp = (fct_i_remote_port_t *)ss->ss_port_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Initial LUN mapped to session ss-%p, irp-%p", ss, irp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_send_cmd_done(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX For now just call send_resp_done() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_cmd_fca_aborted(fct_cmd_t *cmd, fct_status_t s, uint32_t ioflags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((((s != FCT_ABORT_SUCCESS) && (s != FCT_NOT_FOUND))) ||
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan "fct_cmd_fca_aborted: cmd-%p, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_RFLAG_FATAL_ERROR | STMF_RFLAG_RESET, info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_and_32(&icmd->icmd_flags, ~ICMD_KNOWN_TO_FCA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* For non FCP Rest of the work is done by the terminator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* For FCP stuff just call stmf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_task_lport_aborted((scsi_task_t *)cmd->cmd_specific,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FCA drivers will use it, when they want to abort some FC transactions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * due to lack of resource.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_get_rp_handle(fct_local_port_t *port, uint32_t rportid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (fct_i_local_port_t *)(port->port_fct_private), rportid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0xFFFF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_handle_to_cmd(fct_local_port_t *port, uint32_t fct_handle)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ndx = CMD_HANDLE_SLOT_INDEX(fct_handle)) >= port->port_max_xchges)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte slot = &((fct_i_local_port_t *)port->port_fct_private)->iport_cmd_slots[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((slot->slot_uniq_cntr | 0x80) != (fct_handle >> 24))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_queue_scsi_task_for_termination(fct_cmd_t *cmd, fct_status_t s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((old & (ICMD_BEING_ABORTED | ICMD_KNOWN_TO_FCA)) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (atomic_cas_32(&icmd->icmd_flags, old, new) != old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_abort(STMF_QUEUE_TASK_ABORT, (scsi_task_t *)cmd->cmd_specific,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_rcvd_abts_t *abts = (fct_rcvd_abts_t *)cmd->cmd_specific;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure local port is sane */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((iport->iport_link_state & S_LINK_ONLINE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(iport->iport_alias, "ABTS not posted becasue"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_queue_cmd_for_termination(cmd, FCT_LOCAL_PORT_OFFLINE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte irp = fct_portid_to_portptr(iport, cmd->cmd_rportid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (cmd->cmd_rp_handle < port->port_max_logins)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX Throw a logout to the initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(iport->iport_alias, "ABTS received from"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_queue_cmd_for_termination(cmd, FCT_NOT_LOGGED_IN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No need to allocate an xchg resource. ABTSes use the same
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xchg resource as the cmd they are aborting.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Lets find the command first */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ic = iport->iport_cmd_slots[i].slot_cmd) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found the command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dont even bother queueing it. Just respond */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * XXX Throw HBA fatal error event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Later shutdown svc will terminate the ABTS in the end
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_handle_rcvd_abts: iport-%p, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ABTS_ACC port_send_cmd_response failed",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_RFLAG_FATAL_ERROR | STMF_RFLAG_RESET, info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if this an abts retry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (c->cmd_link && (ic->icmd_flags & ICMD_ABTS_RECEIVED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Kill this abts. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_q_for_termination_lock_held(iport, icmd, FCT_ABORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&ic->icmd_flags, ICMD_ABTS_RECEIVED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_queue_cmd_for_termination(c, FCT_ABTS_RECEIVED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_queue_cmd_for_termination(fct_cmd_t *cmd, fct_status_t s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_local_port_t *iport = (fct_i_local_port_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fct_i_cmd_t *icmd = (fct_i_cmd_t *)cmd->cmd_fct_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function will not be called for SCSI CMDS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_q_for_termination_lock_held(fct_i_local_port_t *iport, fct_i_cmd_t *icmd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (atomic_cas_32(&icmd->icmd_flags, old, new) != old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (ppicmd = &(iport->iport_abort_queue); *ppicmd != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For those cmds, for which we called fca_abort but it has not yet completed,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reset the FCA_ABORT_CALLED flag, so that abort can be called again.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is done after a FCA offline. The reason is that after offline, the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * firmware is not running so abort will never complete. But if we call it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * again, the FCA will detect that it is not offline and it will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not call the firmware at all. Most likely it will abort in a synchronous
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * manner i.e. return FCT_ABORT_SUCCESS or FCT_NOT_FOUND.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_reset_flag_abort_called(fct_i_local_port_t *iport)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < iport->iport_port->port_max_xchges; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (atomic_cas_32(&icmd->icmd_flags, old, new) != old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (icmd->icmd_cmd->cmd_type == FCT_CMD_FCP_XCHG)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify the irp_deregister_timer such that the ports start deregistering
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_irp_deregister_speedup(fct_i_local_port_t *iport)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rportid_table_size; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_handle_port_offline(fct_i_local_port_t *iport)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iport->iport_offline_prstate == FCT_OPR_START) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_offline_prstate = FCT_OPR_CMD_CLEANUP_WAIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fct_ctl has already submitted a link offline event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iport->iport_offline_prstate == FCT_OPR_CMD_CLEANUP_WAIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iport->iport_link_state != PORT_STATE_LINK_DOWN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * All I/Os have been killed at this time. Lets speedup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the port deregister process.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iport->iport_offline_prstate = FCT_OPR_INT_CLEANUP_WAIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iport->iport_offline_prstate == FCT_OPR_INT_CLEANUP_WAIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A port logout may have gone when implicit logo all
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * was retried. So do the port speedup again here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See stmf.h for information on rflags. Additional info is just a text
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * description of the reason for this call. Additional_info can be NULL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Also the caller can declare additional info on the stack. stmf_ctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * makes a copy of it before returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_port_initialize(fct_local_port_t *port, uint32_t rflags,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(NULL, "fct_port_initialize: port-%p, %s", port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte additional_info? additional_info : "no more information");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (stmf_ctl(STMF_CMD_LPORT_ONLINE, port->port_lport, &st));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_port_shutdown(fct_local_port_t *port, uint32_t rflags,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(NULL, "fct_port_shutdown: port-%p, %s", port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte additional_info? additional_info : "no more information");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (stmf_ctl(STMF_CMD_LPORT_OFFLINE, port->port_lport, &st));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called by worker thread. The aim is to terminate the command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * using whatever means it takes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called with worker lock held.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Lets Limit each run to 20ms max. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Start from where we left off last time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Once a command gets on discovery queue, this is the only thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which can access it. So no need for the lock here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Always remember that cmd->cmd_rp can be NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&icmd->icmd_flags, ICMD_FCA_ABORT_CALLED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort_ret = port->port_abort_cmd(port, cmd, flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * XXX trigger port fatal,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Abort the termination, and shutdown
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * svc will trigger fct_cmd_termination
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "fct_cmd_terminator:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " iport-%p, port_abort_cmd with "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "FORCE_FCA_DONE failed",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atomic_or_32(&icmd->icmd_flags, ICMD_FCA_ABORT_CALLED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the cmd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IMPLICIT LOGO is special */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Tell the caller that we are done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 10 seconds by default */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* timeout, reset the port */
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan "fct_cmd_terminator:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " iport-%p, cmd_type(0x%s),"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Send a syslog event for adapter port level events.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_log_local_port_event(fct_local_port_t *port, char *subclass)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_add_uint32(attr_list, "instance", port_instance)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_log_sysevent(fct_dip, DDI_VENDOR_SUNW, EC_SUNFC,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(((fct_i_local_port_t *)port->port_fct_private)->iport_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_log_remote_port_event(fct_local_port_t *port, char *subclass,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_add_uint32(attr_list, "instance", port_instance)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_add_byte_array(attr_list, "target-port-wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_add_uint32(attr_list, "target-port-id",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_log_sysevent(fct_dip, DDI_VENDOR_SUNW, EC_SUNFC,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_trace(((fct_i_local_port_t *)port->port_fct_private)->iport_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_value_to_netbuf(uint64_t value, uint8_t *buf, uint8_t nbytes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf[idx] = 0xFF & (value >> (8 * (nbytes - idx - 1)));
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer * from_ptr: ptr to uchar_t array of size WWN_SIZE
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer * to_ptr: char ptr to string of size WWN_SIZE*2+1
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramerfct_wwn_to_str(char *to_ptr, const uint8_t *from_ptr)
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (void) sprintf(to_ptr, "%02x%02x%02x%02x%02x%02x%02x%02x",
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer from_ptr[0], from_ptr[1], from_ptr[2], from_ptr[3],
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer from_ptr[4], from_ptr[5], from_ptr[6], from_ptr[7]);
c946faca5d4627284fb79c6b04e652b471034495allan iport->iport_port, NULL, (uint8_t *)&stat, &buf_size);
c946faca5d4627284fb79c6b04e652b471034495allan return (0);
c946faca5d4627284fb79c6b04e652b471034495allan (void) sprintf(name, "iport_%"PRIxPTR"", (uintptr_t)iport);
c946faca5d4627284fb79c6b04e652b471034495allan ks = kstat_create(FCT_MODULE_NAME, 0, name, "rawdata",
c946faca5d4627284fb79c6b04e652b471034495allan KSTAT_TYPE_NAMED, sizeof (fct_port_stat_t) / sizeof (kstat_named_t),