d62bc4badc1c1f1549c961cfb8b420e650e1272byz * CDDL HEADER START
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * The contents of this file are subject to the terms of the
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Common Development and Distribution License (the "License").
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * You may not use this file except in compliance with the License.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * See the License for the specific language governing permissions
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * and limitations under the License.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * When distributing Covered Code, include this CDDL HEADER in each
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * If applicable, add the following below this CDDL HEADER, with the
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * fields enclosed by brackets "[]" replaced with your own identifying
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * information: Portions Copyright [yyyy] [name of copyright owner]
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * CDDL HEADER END
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Use is subject to license terms.
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore * Copyright 2015 Garrett D'Amore <garret@damore.org>
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Must be the same order as mac_driver_stat.
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China#define SOFTMAC_DRIVER_SI_SZ \
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China (sizeof (i_softmac_driver_si) / sizeof (i_softmac_driver_si[0]))
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Must be the same order as ether_stat.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz "alignment_err" },
d62bc4badc1c1f1549c961cfb8b420e650e1272byz { ETHER_STAT_FIRST_COLLISIONS, "first_collisions", NULL },
d62bc4badc1c1f1549c961cfb8b420e650e1272byz { ETHER_STAT_MULTI_COLLISIONS, "multi_collisions", NULL },
d62bc4badc1c1f1549c961cfb8b420e650e1272byz "late_collisions" },
d62bc4badc1c1f1549c961cfb8b420e650e1272byz "excessive_collisions" },
d62bc4badc1c1f1549c961cfb8b420e650e1272byz { ETHER_STAT_TOOLONG_ERRORS, "toolong_errors", "length_err" },
d62bc4badc1c1f1549c961cfb8b420e650e1272byz "Rx Error Count" },
d62bc4badc1c1f1549c961cfb8b420e650e1272byz { ETHER_STAT_ADV_CAP_ASMPAUSE, "adv_cap_asmpause", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_LP_CAP_100T4, "lp_cap_100T4", NULL },
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China { ETHER_STAT_CAP_10GFDX, "cap_10gfdx", NULL },
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China { ETHER_STAT_ADV_CAP_10GFDX, "adv_cap_10gfdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_LP_CAP_1000FDX, "lp_cap_10gfdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_CAP_40GFDX, "cap_40gfdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_ADV_CAP_40GFDX, "adv_cap_40gfdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_LP_CAP_40GFDX, "lp_cap_40gfdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_CAP_100GFDX, "cap_100gfdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_ADV_CAP_100GFDX, "adv_cap_100gfdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_LP_CAP_100GFDX, "lp_cap_100gfdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_CAP_2500FDX, "cap_2500fdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_ADV_CAP_2500FDX, "adv_cap_2500fdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_LP_CAP_2500FDX, "lp_cap_2500fdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_CAP_5000FDX, "cap_5000fdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_ADV_CAP_5000FDX, "adv_cap_5000fdx", NULL },
3bc4925d580ab95c16f1ddd5eb387655cbd16e65Garrett D'Amore { ETHER_STAT_LP_CAP_5000FDX, "lp_cap_5000fdx", NULL },
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China#define SOFTMAC_ETHER_SI_SZ \
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China (sizeof (i_softmac_ether_si) / sizeof (i_softmac_ether_si[0]))
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic int softmac_get_kstat(kstat_t *, char *, uint64_t *);
d62bc4badc1c1f1549c961cfb8b420e650e1272byz if (ddi_parse(softmac->smac_devname, drv, &ppa) != DDI_SUCCESS)
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Find the kstat by the module name and the instance number.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz ksp = kstat_hold_byname(drv, ppa, softmac->smac_devname, ALL_ZONES);
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Update the kstat to get the latest statistics.
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic void
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * The kstat needs to be held when calling this function.
d62bc4badc1c1f1549c961cfb8b420e650e1272byzsoftmac_get_kstat(kstat_t *ksp, char *name, uint64_t *valp)
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Search the kstat with the given name.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz for (i = 0, knp = KSTAT_NAMED_PTR(ksp); i < ksp->ks_ndata; i++, knp++) {
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China i_softmac_stat_info_t *ssip = NULL;
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China for (index = 0; index < SOFTMAC_DRIVER_SI_SZ; index++) {
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China if (stat == i_softmac_driver_si[index].ssi_stat) {
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China ssip = &i_softmac_driver_si[index];
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China if (ssip == NULL) {
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China if ((ret = softmac_get_kstat(ksp, ssip->ssi_name,
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China ret = softmac_get_kstat(ksp, ssip->ssi_alias,
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China case DL_ETHER: {
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China i_softmac_stat_info_t *ssip = NULL;
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China for (index = 0; index < SOFTMAC_ETHER_SI_SZ; index++) {
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China i_softmac_ether_si[index].ssi_stat) {
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China ssip = &i_softmac_ether_si[index];
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China if (ssip == NULL) {
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China if ((ret = softmac_get_kstat(ksp,
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China ssip->ssi_name, val)) != 0)
aca118b711d5dc86653e0b3c1a122a6b93a0112dlucy wang - Sun Microsystems - Beijing China ret = softmac_get_kstat(ksp,