uint64_t mac_driver_stat_default(mac_impl_t *mip, uint_t stat) { uint_t stat_index; if (IS_MAC_STAT(stat)) { stat_index = stat - MAC_STAT_MIN; ASSERT(stat_index < MAC_NKSTAT); return (i_mac_si[stat_index].msi_default); } ASSERT(IS_MACTYPE_STAT(stat)); stat_index = stat - MACTYPE_STAT_MIN; ASSERT(stat_index < mip->mi_type->mt_statcount); return (mip->mi_type->mt_stats[stat_index].msi_default); }
int softmac_m_stat(void *arg, uint_t stat, uint64_t *val) { softmac_t *softmac = arg; kstat_t *ksp; uint_t index; int ret; if ((ksp = softmac_hold_dev_kstat(softmac)) == NULL) return (ENOTSUP); if (IS_MAC_STAT(stat)) { i_softmac_stat_info_t *ssip = NULL; for (index = 0; index < SOFTMAC_DRIVER_SI_SZ; index++) { if (stat == i_softmac_driver_si[index].ssi_stat) { ssip = &i_softmac_driver_si[index]; break; } } if (ssip == NULL) { ret = ENOTSUP; } else { if ((ret = softmac_get_kstat(ksp, ssip->ssi_name, val)) != 0) ret = softmac_get_kstat(ksp, ssip->ssi_alias, val); } } else { ASSERT(IS_MACTYPE_STAT(stat)); switch (softmac->smac_media) { case DL_ETHER: { i_softmac_stat_info_t *ssip = NULL; for (index = 0; index < SOFTMAC_ETHER_SI_SZ; index++) { if (stat == i_softmac_ether_si[index].ssi_stat) { ssip = &i_softmac_ether_si[index]; break; } } if (ssip == NULL) { ret = ENOTSUP; } else { if ((ret = softmac_get_kstat(ksp, ssip->ssi_name, val)) != 0) ret = softmac_get_kstat(ksp, ssip->ssi_alias, val); } break; } default: ret = ENOTSUP; break; } } softmac_rele_dev_kstat(ksp); return (ret); }