vgen_stats.c revision f0ca1d9a12d54d304791bc74525e2010ca924726
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * CDDL HEADER START
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * The contents of this file are subject to the terms of the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Common Development and Distribution License (the "License").
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * You may not use this file except in compliance with the License.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * See the License for the specific language governing permissions
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * and limitations under the License.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * When distributing Covered Code, include this CDDL HEADER in each
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If applicable, add the following below this CDDL HEADER, with the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * fields enclosed by brackets "[]" replaced with your own identifying
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * information: Portions Copyright [yyyy] [name of copyright owner]
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * CDDL HEADER END
f0ca1d9a12d54d304791bc74525e2010ca924726sb * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Use is subject to license terms.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#pragma ident "%Z%%M% %I% %E% SMI"
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * A set of common kstat statistics related functions that are
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * used by both vnet and vsw drivers to maintain the statistics specific
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Setup kstats for the LDC statistics.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * NOTE: the synchronization for the statistics is the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * responsibility of the caller.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram size = sizeof (vgen_kstats_t) / sizeof (kstat_named_t);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ksp = kstat_create(ks_mod, instance, ks_name, "net", KSTAT_TYPE_NAMED,
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* MIB II kstat variables */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* Tx stats */
f0ca1d9a12d54d304791bc74525e2010ca924726sb kstat_named_init(&ldckp->tx_pri_packets, "tx_pri_packets",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* Rx stats */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kstat_named_init(&ldckp->rx_allocb_fail, "rx_allocb_fail",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kstat_named_init(&ldckp->rx_vio_allocb_fail, "rx_vio_allocb_fail",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kstat_named_init(&ldckp->rx_lost_pkts, "rx_lost_pkts",
f0ca1d9a12d54d304791bc74525e2010ca924726sb kstat_named_init(&ldckp->rx_pri_packets, "rx_pri_packets",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* Interrupt stats */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kstat_named_init(&ldckp->dring_data_acks, "dring_data_acks",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kstat_named_init(&ldckp->dring_stopped_acks, "dring_stopped_acks",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kstat_named_init(&ldckp->dring_data_msgs, "dring_data_msgs",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Destroy kstats.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Update the kstats.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * MIB II kstat variables
f0ca1d9a12d54d304791bc74525e2010ca924726sb ldckp->tx_pri_packets.value.ull = statsp->tx_pri_packets;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldckp->rx_allocb_fail.value.ul = statsp->rx_allocb_fail;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldckp->rx_vio_allocb_fail.value.ul = statsp->rx_vio_allocb_fail;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldckp->rx_lost_pkts.value.ul = statsp->rx_lost_pkts;
f0ca1d9a12d54d304791bc74525e2010ca924726sb ldckp->rx_pri_packets.value.ull = statsp->rx_pri_packets;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldckp->dring_data_acks.value.ul = statsp->dring_data_acks;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldckp->dring_stopped_acks.value.ul = statsp->dring_stopped_acks;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ldckp->dring_data_msgs.value.ul = statsp->dring_data_msgs;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * MIB II kstat variables
f0ca1d9a12d54d304791bc74525e2010ca924726sb statsp->tx_pri_packets = ldckp->tx_pri_packets.value.ull;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram statsp->rx_allocb_fail = ldckp->rx_allocb_fail.value.ul;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram statsp->rx_vio_allocb_fail = ldckp->rx_vio_allocb_fail.value.ul;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram statsp->rx_lost_pkts = ldckp->rx_lost_pkts.value.ul;
f0ca1d9a12d54d304791bc74525e2010ca924726sb statsp->rx_pri_packets = ldckp->rx_pri_packets.value.ull;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram statsp->dring_data_acks = ldckp->dring_data_acks.value.ul;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram statsp->dring_stopped_acks = ldckp->dring_stopped_acks.value.ul;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram statsp->dring_data_msgs = ldckp->dring_data_msgs.value.ul;
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);