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
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Software Initiator
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortekstat_item_t kstat_items_sess[KN_SESS_IDX_MAX] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortekstat_item_t kstat_items_conn[KN_CONN_IDX_MAX] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_hba_kstat_init - This function registers with the kstat service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The name of the KSTAT structure is built.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(ks_name, sizeof (ks_name) - 1, iSCSI_HBA_BASE_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_get_instance(ihp->hba_dip), ks_name, iSCSI_CLASS_HBA,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_NOTE, "iscsi kstat creation failed for hba(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ihp->stats.ks->ks_data_size = sizeof (ihp->stats.ks_data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < KN_HBA_IDX_MAX; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_init(&ihs->kn[i], kstat_items_hba[i]._name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ihp->stats.ks->ks_update = iscsi_hba_kstat_update;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_hba_kstat_term - This function deregisters from the kstat service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_hba_kstat_update - This function update the kstat structure of the HBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_hba_t *ihp = (iscsi_hba_t *)ks->ks_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ihp->hba_name, ihs->name, ihp->hba_name_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ihp->hba_alias, ihs->alias, ihp->hba_alias_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_sess_kstat_init - This function registers with the kstat service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The name of the KSTAT structure is built.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(ks_name, sizeof (ks_name) - 1, iSCSI_SESS_BASE_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp->sess_hba->hba_oid, isp->sess_oid) >= sizeof (ks_name)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_NOTE, "iscsi kstat creation failed for "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_get_instance(ihp->hba_dip), ks_name, iSCSI_CLASS_SESS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp->stats.ks->ks_data = (void *)&isp->stats.ks_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp->stats.ks->ks_data_size = sizeof (isp->stats.ks_data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < KN_SESS_IDX_MAX; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_init(&iss->kn[i], kstat_items_sess[i]._name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The static information is updated immediately */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ihp->stats.ks->ks_name, iss->hba_str, sizeof (iss->hba_str));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iss->kn[KN_SESS_IDX_OID].value.ul = isp->sess_oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp->stats.ks->ks_update = iscsi_sess_kstat_update;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The IO KSTAT structure is created */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(ks_name, sizeof (ks_name) - 1, iSCSI_SESS_IO_BASE_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp->sess_hba->hba_oid, isp->sess_oid) >= sizeof (ks_name)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp->stats.ks_io = kstat_create(iSCSI_MODULE_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_get_instance(ihp->hba_dip), ks_name, iSCSI_CLASS_SESS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&isp->stats.ks_io_lock, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp->stats.ks_io->ks_data = &isp->stats.ks_io_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isp->stats.ks_io->ks_lock = &isp->stats.ks_io_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_sess_kstat_term - This function deregisters with the kstat service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_sess_kstat_update - This function update the kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure of the HBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sess_t *isp = (iscsi_sess_t *)ks->ks_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* String indicating the state of the session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Target name string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isp->sess_name_length > sizeof (iss->target_name)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(iss->target_name, sizeof (iss->target_name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_setstr(&iss->kn[KN_SESS_IDX_TARGET_NAME],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Target alias string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isp->sess_alias_length > sizeof (iss->target_alias)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(iss->target_alias, sizeof (iss->target_alias));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Connection
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_conn_kstat_init - This function registers with the kstat service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The name of the KSTAT structure is built.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(ks_name, sizeof (ks_name) - 1, iSCSI_CONN_BASE_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icp->conn_sess->sess_hba->hba_oid, icp->conn_sess->sess_oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_get_instance(ihp->hba_dip), ks_name, iSCSI_CLASS_CONN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < KN_CONN_IDX_MAX; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_init(&ics->kn[i], kstat_items_conn[i]._name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The static information is updated immediately */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ics->kn[KN_CONN_IDX_OID].value.ul = isp->sess_oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ics->kn[KN_CONN_IDX_CID].value.ul = icp->conn_cid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icp->stats.ks->ks_update = iscsi_conn_kstat_update;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_conn_kstat_term - This function deregisters with the kstat service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_conn_kstat_update - This function update the kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure of the HBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_conn_t *icp = (iscsi_conn_t *)ks->ks_private;