9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * CDDL HEADER START
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The contents of this file are subject to the terms of the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Common Development and Distribution License (the "License").
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * You may not use this file except in compliance with the License.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * See the License for the specific language governing permissions
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * and limitations under the License.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * When distributing Covered Code, include this CDDL HEADER in each
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * If applicable, add the following below this CDDL HEADER, with the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * fields enclosed by brackets "[]" replaced with your own identifying
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * information: Portions Copyright [yyyy] [name of copyright owner]
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * CDDL HEADER END
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Use is subject to license terms.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Retrieves the statistics for a specified port.phy on an adapter
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_STATUS Sun_sasGetPhyStatistics(HBA_HANDLE handle,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBA_UINT32 port, HBA_UINT32 phy, SMHBA_PHYSTATISTICS *pStatistics) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Validate the arguments */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "NULL Phy Statistics buffer of phyIndex: %08lx", phy);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "NULL SAS Phy Statistics buffer of phyIndex: %08lx", phy);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((hba_ptr = Retrieve_Sun_sasHandle(handle)) == NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "Invalid HBA handler %08lx of phyIndex: %08lx",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Check for stale data */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (phy >= hba_port_ptr->port_attributes.PortSpecificAttribute.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim log(LOG_DEBUG, ROUTINE, "Invalid phy index %08lx", phy);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* We need to find out the phy identifier. */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim log(LOG_DEBUG, ROUTINE, "Invalid phy index %08lx", phy);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * for statistics that are not supported, its bits should all be
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * set to -1
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* First, we need the deivce path to locate the devinfo node. */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void *) memset(kstat_name, 0, sizeof (kstat_name));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "Unable to take devinfo snapshot on HBA \"%s\" "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "for phyIndex: %08lx due to %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Then we could fetch the instance number and driver name of this
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "An instance number has not been assigned to the "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "device \"%s\" when get phyIndex: %08lx", path, phy);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "No driver bound to this device \"%s\" "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "when get phyIndex: %08lx",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim iport_wwn = wwnConversion(hba_port_ptr->port_attributes.\
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim PortSpecificAttribute.SASPort->LocalSASAddress.wwn);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Construct the kstat name here.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) snprintf(kstat_name, sizeof (kstat_name), "%s.%016llx.%u.%u",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim driver_name, iport_wwn, instance, phy_ptr->phy.PhyIdentifier);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* retrieve all the statistics from kstat. */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "kstat_open failed due to \"%s\" of phyIndex: %08lx",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "No matching kstat name found for \"%s\" "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "of phyIndex: %08lx",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Found the phy we're looking for. */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "error reading kstat data due to \"%s\" "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "of phyIndex: %08lx",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "SecondsSinceLastReset") == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (strcmp(kname->name, "InvalidDwordCount") == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (strcmp(kname->name, "RunningDisparityErrorCount") == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim psas->RunningDisparityErrorCount = kname->value.ull;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (strcmp(kname->name, "LossofDwordSyncCount") == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (strcmp(kname->name, "PhyResetProblemCount") == 0) {