fcoet.h revision 87dcbdbdce8044d5199e015edd8fb347d16ee0b5
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
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Use is subject to license terms.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * FCOET logging
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Caution: 1) LOG will be available in debug/non-debug mode
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * 2) Anything which can potentially flood the log should be under
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * extended logging, and use FCOET_EXT_LOG.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * 3) Don't use FCOET_EXT_LOG in performance-critical code path, such
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * as normal SCSI I/O code path. It could hurt system performance.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * 4) Use kmdb to change focet_use_ext_log in the fly to adjust
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * define common-used constants
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * define data structures
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangtypedef struct fcoet_soft_state {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * basic information
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * support degregister remote port
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * watch thread related stuff
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * topology discovery
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * ioctl related stuff
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * special stuff
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Sequence and frame are transient objects, so their definition is simple.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * we will not use sequence in current implementation
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangtypedef struct fcoet_sequence {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangtypedef struct fcoet_frame {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * FCOET_MAX_DBUF_LEN should better be consistent with sbd_scsi.c. Since
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * sbd_scsi.c use 128k as the max dbuf size, we'd better define this between
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * 32k - 128k.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define FCOET_MAX_DBUF_LEN 0x20000 /* 128 * 1024 */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * exchange - cmd alias
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangtypedef struct fcoet_exchange {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * it is only used for ss_abort_xchg_list
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * We don't believe oxid/rxid in fct_cmd_t
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Add the reference to avoid such situation:
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * 1, Frame received, then abort happen (maybe because local port offline, or
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * remote port abort the cmd), cmd is aborted and then freed right after we
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * get the exchange from hash table in fcoet_rx_frame.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * 2, Frame sent out, then queued in fcoe for release. then abort happen, cmd
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * is aborted and then freed before fcoe_watchdog() call up to release the
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * These two situation should seldom happen. But just invoke this seems won't
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * downgrade the performance too much, so we keep it.
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define FCOET_BUSY_XCHG(xch) atomic_add_8(&(xch)->xch_ref, 1)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define FCOET_RELE_XCHG(xch) atomic_add_8(&(xch)->xch_ref, -1)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * IOCTL supporting stuff
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * define common-used conversion and calculation macros
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ((fcoet_soft_state_t *)(x_frm)->frm_eport->eport_client_private)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define FRM2TFM(x_frm) ((fcoet_frame_t *)(x_frm)->frm_client_private)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define PORT2SS(x_port) ((fcoet_soft_state_t *)(x_port)->port_fca_private)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define EPORT2SS(x_port) ((fcoet_soft_state_t *)(x_port)->eport_client_private)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define XCH2ELS(x_xch) ((fct_els_t *)x_xch->xch_cmd->cmd_specific)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define XCH2CT(x_xch) ((fct_ct_t *)x_xch->xch_cmd->cmd_specific)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define XCH2TASK(x_xch) ((scsi_task_t *)x_xch->xch_cmd->cmd_specific)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define CMD2ELS(x_cmd) ((fct_els_t *)x_cmd->cmd_specific)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define CMD2CT(x_cmd) ((fct_sol_ct_t *)x_cmd->cmd_specific)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define CMD2TASK(x_cmd) ((scsi_task_t *)x_cmd->cmd_specific)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define CMD2XCH(x_cmd) ((fcoet_exchange_t *)x_cmd->cmd_fca_private)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ((fcoet_soft_state_t *)(x_cmd)->cmd_port->port_fca_private)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangvoid fcoet_init_tfm(fcoe_frame_t *frm, fcoet_exchange_t *xch);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangvoid fcoet_modhash_find_cb(mod_hash_key_t, mod_hash_val_t);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * DBUF stuff
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define FCOET_DB_SEG_NUM(x_db) (x_db->db_port_private)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang sizeof (struct stmf_sglist_ent) + (uintptr_t)(x_db)->db_sglist)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_DB_SEG_NUM(x_db) = (void *)(unsigned long)x_num; \
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define FCOET_GET_SEG_NUM(x_db) ((int)(unsigned long)FCOET_DB_SEG_NUM(x_db))
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang ((void **)FCOET_DB_NETB(x_db))[x_idx] = x_netb; \
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang FCOET_LOG(x_p, "rctl/%x, type/%x, fctl/%x, oxid/%x", \
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#endif /* _KERNEL */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#endif /* _FCOET_H */