fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _ISCSI_STATS_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _ISCSI_STATS_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file contains all the definitions and prototypes relevant to KSTAT.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It also contains the declaration and initialization of data. When including
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this file, if _INIT_KSTAT_DATA_ is defined, the data is declared AND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialized. As a consequence, this file should be included only once with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _INIT_KSTAT_DATA_ defined. Failure to do so will lead to a link error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Today, iscsi_stats.c is the only file defining _INIT_KSTAT_DATA_.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Four types of KSTAT structures are created for iSCSI.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sun_iscsi_hba
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This structure gathers statistics relevant to an HBA. Each HBA or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * software state structure is given one. It contains the following
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fieds:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _name iSCSI name of the HBA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _alias iSCSI alias of the HBA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cntr_sess Numbers of sessions created
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sun_iscsi_sess
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * --------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This structure gathers statistics relevant to a session. Each session
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is given one. It contains the following fields:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _state State of the session
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _oid OID of the session
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _hba HBA the session belongs to. It is the name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of the sun_iscsi_hba structure of the HBA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cntr_conn Number of connections
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cntr_pkt_pending Number of scsi_pkt in the pending queue
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cmd_sn CmdSN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cmd_sn_exp CmdSNExp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cmd_sn_max CmdSNMax
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sun_iscsi_sess_io
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -----------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This structure is completely defined by the KSTAT frame work of Solaris.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It contains accumulated time and queue length statistics. It assumes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the driver has a pending queue and an active. In our implementation,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the pending queue is the pending queue defined in the session context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The active queue is any queue defined in the connection context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If you want more information about the meaning of the fields of this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure you can read the nice explanation contained in the file:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /usr/src/uts/common/sys/kstat.h.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * At any rate, all the sessions are given a sun_iscsi_sess_io structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The fields are:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nread number of bytes read without iSCSI overhead.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nwritten number of bytes written without iSCSI overhead.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reads number of read operations
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * writes number of write operations
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wtime cumulative wait (pre-service) time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wlentime cumulative wait length*time product
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wlastupdate last time wait queue changed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rtime cumulative run (service) time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rlentime cumulative run length*time product
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rlastupdate last time run queue changed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wcnt count of elements in wait state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rcnt count of elements in run state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The time is expressed in nanoseconds.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sun_iscsi_conn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * --------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This structure gathers statistics relevant to a connection. Each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * connection is given one. It contains the following fields:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _state State of the connection
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cid iSCSI CID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _oid OID of the connection
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _session Session the connection belongs to. It is the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name of the sun_iscsi_sess structure of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * session.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _err_header_digest Number of header digest errors
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _err_data_digest Number of data digest errors
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _err_connection_reset Number of reset
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _err_protocol_error Number of protocol errors
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cntr_tx_bytes Number of bytes transmitted with iSCSI overhead.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cntr_rx_bytes Number of bytes received with iSCSI overhead.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _cntr_qactive Number of requests in the active queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _stat_sn_exp ExpStatusSN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _stat_sn_last LastStatusSN (Last one sent to the target)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The KSTAT frame work of Solaris associates a module name, a instance number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a class and a name to every kstat structure. All the kstat structures of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI have the same module name. It is define farther down in this file to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "iscsi". Regarding the class, three classes are defined here. Those classes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - issci_hba
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - iscsi_sess
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - iscsi_conn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The instance number is the number returned by ddi_get_instance. Today the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the driver creates one HBA only. Therefore, all the structures will have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero as instance number.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Each kstat structure can be named. The naming convention is the following:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * KSTAT Struct Class Name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sun_iscsi_hba iscsi_hba "sun_iscsi_hba" + instance number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sun_iscsi_sess iscsi_sess "sun_iscsi_sess" + session oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sun_iscsi_sess_io iscsi_sess "sun_iscsi_sess_io" + session oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sun_iscsi_conn iscsi_conn "sun_iscsi_conn" + connection oid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * strings used by kstat (Module name and Class name).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define iSCSI_MODULE_NAME "iscsi"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _kstat_item {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t _data_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} kstat_item_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ========================= Connection Class Section ======================
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define iSCSI_CLASS_CONN "iscsi_conn"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define iSCSI_CONN_BASE_NAME "iscsi_conn_%d_%d_%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_STATE_FREE_STR "free"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_STATE_IN_LOGIN_STR "in_login"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_STATE_LOGGED_IN_STR "logged_in"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_STATE_IN_LOGOUT_STR "in_logout"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_STATE_CLEANUP_WAIT_STR "cleanup_wait"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * WARNING: The order of this enum important. If you change it you have to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reorder the table kstat_items_conn (in the file iscsi_stats.c)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * accordingly.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum _kn_conn_idx {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_STATE = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_CID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_OID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_SESS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_ERR_HDR_DIGEST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_ERR_DATA_DIGEST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_ERR_CONN_RESET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_ERR_PROTOCOL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_CNTR_TX_BYTES,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_CNTR_RX_BYTES,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_CNTR_QACTIVE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_EXPSTATSN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_LASTSTATSN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_CONN_IDX_MAX
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} kn_conn_idx_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _iscsi_conn_kstats {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t kn[KN_CONN_IDX_MAX];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char sess_str[KSTAT_STRLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char state_str[KSTAT_STRLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_conn_stats_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_CONN_ERR_HEADER_DIGEST(_icp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_icp_->stats.ks_data.kn[KN_CONN_IDX_ERR_HDR_DIGEST].value.ul++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_CONN_ERR_DATA_DIGEST(_icp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_icp_->stats.ks_data.kn[KN_CONN_IDX_ERR_DATA_DIGEST].value.ul++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_CONN_ERR_PROTOCOL(_icp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_icp_->stats.ks_data.kn[KN_CONN_IDX_ERR_PROTOCOL].value.ul++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_CONN_ERR_RESET(_icp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_icp_->stats.ks_data.kn[KN_CONN_IDX_ERR_CONN_RESET].value.ul++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_ADD_CONN_TX_BYTES(_icp_, _v_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_icp_->stats.ks_data.kn[KN_CONN_IDX_CNTR_TX_BYTES].value.ui64 += \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _v_)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_ADD_CONN_RX_BYTES(_icp_, _v_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_icp_->stats.ks_data.kn[KN_CONN_IDX_CNTR_RX_BYTES].value.ui64 += \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _v_)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ========================== Session Class Section ========================
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Session Class */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define iSCSI_CLASS_SESS "iscsi_sess"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define iSCSI_SESS_BASE_NAME "iscsi_sess_%d_%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define iSCSI_SESS_IO_BASE_NAME "iscsi_sess_io_%d_%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SESS_STATE_FREE_STR "free"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SESS_STATE_LOGGED_IN_STR "logged_in"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SESS_STATE_FAILED_STR "failed"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * WARNING: The order of this enum important. If you change it you have to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reorder the table kstat_items_sess (in the file iscsi_stats.c)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * accordingly.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum _kn_sess_idx {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_STATE = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_OID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_HBA,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_CNTR_CONN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_CNTR_RESET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_CNTR_PKT_PENDING,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_CMDSN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_EXPCMDSN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_MAXCMDSN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_TARGET_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_TARGET_ALIAS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_TPGT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_SESS_IDX_MAX
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} kn_sess_idx_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _iscsi_sess_stats {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t kn[KN_SESS_IDX_MAX];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char hba_str[KSTAT_STRLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char state_str[KSTAT_STRLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char target_name[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char target_alias[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_sess_stats_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_SESS_CNTR_RESET(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_data.kn[KN_SESS_IDX_CNTR_RESET].value.ul++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_SESS_CNTR_CONN(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_data.kn[KN_SESS_IDX_CNTR_CONN].value.ul++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_DEC_SESS_CNTR_CONN(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_data.kn[KN_SESS_IDX_CNTR_CONN].value.ul--)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_ADD_SESS_CNTR_TX_BYTES(_isp_, _v_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_io_data.nwritten += _v_); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_ADD_SESS_CNTR_RX_BYTES(_isp_, _v_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_io_data.nread += _v_); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_SESS_CNTR_NWRITES(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_io_data.writes++); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_SESS_CNTR_NREADS(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_io_data.reads++); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_WAITQ_ENTER(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (kstat_waitq_enter(&_isp_->stats.ks_io_data)); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_WAITQ_EXIT(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (kstat_waitq_exit(&_isp_->stats.ks_io_data)); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_RUNQ_ENTER(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (kstat_runq_enter(&_isp_->stats.ks_io_data)); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_RUNQ_EXIT(_isp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (kstat_runq_exit(&_isp_->stats.ks_io_data)); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_SESS_TX_IO_DONE(_isp_, _v_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_io_data.nwritten += _v_); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_io_data.writes++); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_SESS_RX_IO_DONE(_isp_, _v_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&_isp_->stats.ks_io_lock); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_io_data.nread += _v_); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_isp_->stats.ks_io_data.reads++); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&_isp_->stats.ks_io_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ============================ HBA Class Section ==========================
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define iSCSI_CLASS_HBA "iscsi_hba"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define iSCSI_HBA_BASE_NAME "iscsi_hba_%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * WARNING: The order of this enum important. If you change it you have to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reorder the table kstat_items_hba (in iscsi_stats.c) accordingly.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum _kn_hba_idx {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_HBA_IDX_NAME = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_HBA_IDX_ALIAS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_HBA_IDX_CNTR_SESS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KN_HBA_IDX_MAX
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} kn_hba_idx_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _iscsi_hba_stats {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t kn[KN_HBA_IDX_MAX];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char alias[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_hba_stats_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_INC_HBA_CNTR_SESS(_ihp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_ihp_->stats.ks_data.kn[KN_HBA_IDX_CNTR_SESS].value.ul++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_DEC_HBA_CNTR_SESS(_ihp_) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (_ihp_->stats.ks_data.kn[KN_HBA_IDX_CNTR_SESS].value.ul--)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _ISCSI_STATS_H */