2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * CDDL HEADER START
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * The contents of this file are subject to the terms of the
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Common Development and Distribution License (the "License").
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * You may not use this file except in compliance with the License.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * See the License for the specific language governing permissions
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * and limitations under the License.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * When distributing Covered Code, include this CDDL HEADER in each
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * If applicable, add the following below this CDDL HEADER, with the
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * fields enclosed by brackets "[]" replaced with your own identifying
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * information: Portions Copyright [yyyy] [name of copyright owner]
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * CDDL HEADER END
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * The following notice accompanied the original version of this file:
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * BSD LICENSE
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Copyright(c) 2007 Intel Corporation. All rights reserved.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * All rights reserved.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Redistribution and use in source and binary forms, with or without
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * modification, are permitted provided that the following conditions
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * * Redistributions of source code must retain the above copyright
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * notice, this list of conditions and the following disclaimer.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * * Redistributions in binary form must reproduce the above copyright
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * notice, this list of conditions and the following disclaimer in
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * the documentation and/or other materials provided with the
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * distribution.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * * Neither the name of Intel Corporation nor the names of its
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * contributors may be used to endorse or promote products derived
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * from this software without specific prior written permission.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Driver kernel header files
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * COMSTAR header files
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * FCoE header files
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Driver's own header files
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * static function forward declaration
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoet_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoet_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoet_open(dev_t *devp, int flag, int otype, cred_t *credp);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoet_close(dev_t dev, int flag, int otype, cred_t *credp);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoet_ioctl(dev_t dev, int cmd, intptr_t data, int mode,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic fct_status_t fcoet_attach_init(fcoet_soft_state_t *ss);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic fct_status_t fcoet_detach_uninit(fcoet_soft_state_t *ss);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic void fcoet_handle_sol_flogi(fcoet_soft_state_t *ss);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic stmf_data_buf_t *fcoet_dbuf_alloc(fct_local_port_t *port,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang uint32_t size, uint32_t *pminsize, uint32_t flags);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic void fcoet_dbuf_free(fct_dbuf_store_t *fds, stmf_data_buf_t *dbuf);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoet_dbuf_init(fcoet_soft_state_t *ss);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic void fcoet_dbuf_destroy(fcoet_soft_state_t *ss);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_sol_oxid_hash_empty(mod_hash_key_t key, mod_hash_val_t *val, void *arg);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_unsol_rxid_hash_empty(mod_hash_key_t key, mod_hash_val_t *val, void *arg);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Driver identificaton stuff
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Driver's global variables
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic struct stmf_port_provider *fcoet_pp = NULL;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Common loadable module entry points _init, _fini, _info
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ret = ddi_soft_state_init(&fcoet_state, sizeof (fcoet_soft_state_t), 0);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if (stmf_register_port_provider(fcoet_pp) != STMF_SUCCESS) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Autoconfiguration entry points: attach, detach, getinfo
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach", "get instance %d", instance);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ret = ddi_soft_state_zalloc(fcoet_state, instance);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach", "unspported attach cmd-%x", cmd);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_detach", "fcoet_detach_uninit end with-%x",
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_detach", "unsupported detach cmd-%x", cmd);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Device access entry points
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_open(dev_t *devp, int flag, int otype, cred_t *credp)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Since this is for debugging only, only allow root to issue ioctl now
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if (ss->ss_ioctl_flags & FCOET_IOCTL_FLAG_EXCL) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * It is already open for exclusive access.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * So shut the door on this caller.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if (ss->ss_ioctl_flags & FCOET_IOCTL_FLAG_OPEN) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Exclusive operation not possible
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * as it is already opened
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* ARGSUSED */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_close(dev_t dev, int flag, int otype, cred_t *credp)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if ((ss->ss_ioctl_flags & FCOET_IOCTL_FLAG_OPEN) == 0) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * It looks there's one hole here, maybe there could several concurrent
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * shareed open session, but we never check this case.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * But it will not hurt too much, disregard it now.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* ARGSUSED */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_ioctl(dev_t dev, int cmd, intptr_t data, int mode,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ss = ddi_get_soft_state(fcoet_state, (int32_t)getminor(dev));
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan char taskq_name[FCOET_TASKQ_NAME_LEN];
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * FCoE (fcoe is fcoet's dependent driver)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * First we need register fcoet to FCoE as one client
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang client_fcoet.ect_eport_flags = EPORT_FLAG_TGT_MODE |
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang client_fcoet.ect_private_frame_struct_size = sizeof (fcoet_frame_t);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang client_fcoet.ect_release_sol_frame = fcoet_release_sol_frame;
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang FCOET_LOG(__FUNCTION__, "version: %x %x", FCOE_VER_NOW, fcoe_ver_now);
d4401b99a36e5170ccaa7defc0d2ac65b23f08c6Kelly Hu DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "mac_id", -1);
d4401b99a36e5170ccaa7defc0d2ac65b23f08c6Kelly Hu FCOET_LOG("fcoet_attach_init", "get mac_id failed");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * It's FCoE's responsiblity to initialize eport's all elements
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Now it's time to register local port to FCT
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang fds = (fct_dbuf_store_t *)fct_alloc(FCT_STRUCT_DBUF_STORE, 0, 0);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port = (fct_local_port_t *)fct_alloc(FCT_STRUCT_LOCAL_PORT, 0, 0);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Do ss's initialization now
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang (void) snprintf(ss->ss_alias, sizeof (ss->ss_alias), "fcoet%d",
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOE_SET_DEFAULT_FPORT_ADDR(eport->eport_efh_dst);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang mutex_init(&ss->ss_watch_mutex, 0, MUTEX_DRIVER, 0);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang cv_init(&ss->ss_watch_cv, NULL, CV_DRIVER, NULL);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang list_create(&ss->ss_abort_xchg_list, sizeof (fcoet_exchange_t),
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang bzero(&ss->ss_link_info, sizeof (fct_link_info_t));
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang mutex_init(&ss->ss_ioctl_mutex, 0, MUTEX_DRIVER, 0);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Do port's initialization
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * port_fct_private and port_lport have been initialized by fct_alloc
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang bcopy(ss->ss_eport->eport_nodewwn, port->port_nwwn, 8);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang bcopy(ss->ss_eport->eport_portwwn, port->port_pwwn, 8);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_fca_fcp_cmd_size = sizeof (fcoet_exchange_t);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_fca_sol_els_private_size = sizeof (fcoet_exchange_t);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_fca_sol_ct_private_size = sizeof (fcoet_exchange_t);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_fca_abort_timeout = 5 * 1000; /* 5 seconds */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_register_remote_port = fcoet_register_remote_port;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_deregister_remote_port = fcoet_deregister_remote_port;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_xfer_scsi_data = fcoet_xfer_scsi_data;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_send_cmd_response = fcoet_send_cmd_response;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang port->port_populate_hba_details = fcoet_populate_hba_fru_details;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if (fct_register_local_port(port) != FCT_SUCCESS) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Start watchdog thread
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan (void) snprintf(taskq_name, sizeof (taskq_name),
4558d122136f151d62acbbc02ddb42df89a5ef66Viswanathan Kannappan "stmf_fct_fcoet_%d_taskq", ss->ss_instance);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if ((ss->ss_watchdog_taskq = ddi_taskq_create(NULL,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang atomic_and_32(&ss->ss_flags, ~SS_FLAG_TERMINATE_WATCHDOG);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang while ((ss->ss_flags & SS_FLAG_WATCHDOG_RUNNING) == 0) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang atomic_or_32(&ss->ss_flags, SS_FLAG_TERMINATE_WATCHDOG);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang while (ss->ss_flags & SS_FLAG_WATCHDOG_RUNNING) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach_init", "fail_register_port");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach_init", "fail_create_taskq");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach_init", "fail_minor_node");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach_init", "fail_alloc_port");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach_init", "fail_alloc_dbuf");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ss->ss_eport->eport_deregister_client(ss->ss_eport);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach_init", "fail_init_dbuf");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_attach_init", "fail_register_client");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Avoid modunload before running fcinfo remove-target-port
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ss->ss_eport->eport_flags & EPORT_FLAG_MAC_IN_USE) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang mod_hash_walk(ss->ss_sol_oxid_hash, fcoet_sol_oxid_hash_empty, ss);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang mod_hash_walk(ss->ss_unsol_rxid_hash, fcoet_unsol_rxid_hash_empty, ss);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if ((!ss->ss_sol_oxid_hash_empty) || (!ss->ss_unsol_rxid_hash_empty)) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * We need offline the port manually, before we want to detach it
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * or it will not succeed.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if (fct_deregister_local_port(ss->ss_port) != FCT_SUCCESS) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang "fct_deregister_local_port failed");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Stop watchdog
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang atomic_or_32(&ss->ss_flags, SS_FLAG_TERMINATE_WATCHDOG);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang while (ss->ss_flags & SS_FLAG_WATCHDOG_RUNNING) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Release all resources
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ss->ss_eport->eport_deregister_client(ss->ss_eport);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ddi_soft_state_free(fcoet_state, ss->ss_instance);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang fcoet_soft_state_t *ss = (fcoet_soft_state_t *)arg;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_watchdog", "fcoet_soft_state is %p", ss);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang atomic_or_32(&ss->ss_flags, SS_FLAG_WATCHDOG_RUNNING);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang while ((ss->ss_flags & SS_FLAG_TERMINATE_WATCHDOG) == 0) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang for (xchg = list_head(&ss->ss_abort_xchg_list); xchg; ) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang xchg_next = list_next(&ss->ss_abort_xchg_list, xchg);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang /* xchg abort done */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang sizeof (void *));
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang atomic_or_32(&ss->ss_flags, SS_FLAG_DOG_WAITING);
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni (void) cv_reltimedwait(&ss->ss_watch_cv, &ss->ss_watch_mutex,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang atomic_and_32(&ss->ss_flags, ~SS_FLAG_DOG_WAITING);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Ensure no ongoing FLOGI, before terminate the watchdog
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang atomic_and_32(&ss->ss_flags, ~SS_FLAG_WATCHDOG_RUNNING);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * wait for the response to finish
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang if ((ss->ss_sol_flogi->xch_start_time + twosec) <
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * We'd better to offline it first, and delay 0.1 seconds,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * before we say it's on again.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* ARGSUSED */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* ARGSUSED */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* ARGSUSED */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_dbuf_alloc(fct_local_port_t *port, uint32_t size, uint32_t *pminsize,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang sge_num = (size - 1) / ss->ss_fcp_data_payload_size + 1;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang add_size = (sge_num - 1) * sizeof (struct stmf_sglist_ent) +
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang dbuf = stmf_alloc(STMF_STRUCT_DATA_BUF, add_size, 0);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Initialize non-last sg entries
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Initialize the last sg entry
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang sge_size = P2ROUNDUP(size % ss->ss_fcp_data_payload_size, 4);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Let COMSTAR know how many sg entries we will use
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_dbuf_free(fct_dbuf_store_t *fds, stmf_data_buf_t *dbuf)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang for (idx = 0; idx < FCOET_GET_SEG_NUM(dbuf); idx++) {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * We should have initialized fcoe_frame_t before
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_init_tfm(fcoe_frame_t *frm, fcoet_exchange_t *xch)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* ARGSUSED */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_sol_oxid_hash_empty(mod_hash_key_t key, mod_hash_val_t *val, void *arg)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang fcoet_soft_state_t *ss = (fcoet_soft_state_t *)arg;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_sol_oxid_hash_empty", "one ongoing xch: %p", val);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* ARGSUSED */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangfcoet_unsol_rxid_hash_empty(mod_hash_key_t key, mod_hash_val_t *val, void *arg)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang fcoet_soft_state_t *ss = (fcoet_soft_state_t *)arg;
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG("fcoet_unsol_rxid_hash_empty", "one ongoing xch: %p", val);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* ARGSUSED */