/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* MAC Services Module
*/
#include <sys/sysmacros.h>
#include <sys/mac_impl.h>
#include <sys/mac_client_impl.h>
#include <sys/mac_stat.h>
#include <sys/mac_soft_ring.h>
enum mac_stat {
};
};
#define MAC_NKSTAT \
(sizeof (i_mac_si) / sizeof (mac_stat_info_t))
};
#define MAC_MOD_NKSTAT \
(sizeof (i_mac_mod_si) / sizeof (mac_stat_info_t))
#define MAC_MOD_KSTAT_OFFSET 0
/*
* Definitions for per rx ring statistics
*/
};
#define MAC_RX_RING_NKSTAT \
(sizeof (i_mac_rx_ring_si) / sizeof (mac_stat_info_t))
/*
* Definitions for per tx ring statistics
*/
};
#define MAC_TX_RING_NKSTAT \
(sizeof (i_mac_tx_ring_si) / sizeof (mac_stat_info_t))
/*
* Definitions for per software lane tx statistics
*/
};
#define MAC_TX_SWLANE_NKSTAT \
(sizeof (i_mac_tx_swlane_si) / sizeof (mac_stat_info_t))
/*
* Definitions for per software lane rx statistics
*/
};
#define MAC_RX_SWLANE_NKSTAT \
(sizeof (i_mac_rx_swlane_si) / sizeof (mac_stat_info_t))
/*
* Definitions for per hardware lane rx statistics
*/
};
#define MAC_RX_HWLANE_NKSTAT \
(sizeof (i_mac_rx_hwlane_si) / sizeof (mac_stat_info_t))
/*
* Definitions for misc statistics
*/
};
#define MAC_SUMMARY_NKSTAT \
(sizeof (i_mac_misc_si) / sizeof (mac_stat_info_t))
/*
* Definitions for per hardware lane tx statistics
*/
};
#define MAC_TX_HWLANE_NKSTAT \
(sizeof (i_mac_tx_hwlane_si) / sizeof (mac_stat_info_t))
/*
* Definitions for per fanout rx statistics
*/
};
#define MAC_RX_FANOUT_NKSTAT \
(sizeof (i_mac_rx_fanout_si) / sizeof (mac_stat_info_t))
/*
* Private functions.
*/
typedef struct {
} stat_info_t;
};
#define RX_SRS_STAT_SIZE \
(sizeof (rx_srs_stats_list) / sizeof (stat_info_t))
};
#define TX_SOFTRING_STAT_SIZE \
(sizeof (tx_softring_stats_list) / sizeof (stat_info_t))
static void
{
int i;
for (i = 0; i < size; i++) {
}
}
static int
{
uint_t i;
if (rw != KSTAT_READ)
return (EACCES);
if (i == MAC_MOD_KSTAT_OFFSET) {
msi_index = 0;
msi = i_mac_mod_si;
} else if (i == MAC_KSTAT_OFFSET) {
msi_index = 0;
} else if (i == MAC_TYPE_KSTAT_OFFSET) {
msi_index = 0;
}
case KSTAT_DATA_UINT64:
break;
case KSTAT_DATA_UINT32:
break;
default:
break;
}
knp++;
}
return (0);
}
static void
{
int i;
for (i = 0; i < count; i++) {
knp++;
}
}
static int
{
uint_t i;
if (rw != KSTAT_READ)
return (EACCES);
for (i = 0; i < count; i++) {
case KSTAT_DATA_UINT64:
break;
case KSTAT_DATA_UINT32:
break;
default:
break;
}
knp++;
}
return (0);
}
/*
* Create kstat with given name - statname, update function - fn
* and initialize it with given names - init_stat_info
*/
static kstat_t *
{
KSTAT_TYPE_NAMED, count, 0);
return (NULL);
return (ksp);
}
/*
* Per rx ring statistics
*/
{
/*
* XXX Every ring-capable driver must implement an entry point to
* query per ring statistics. CR 6893122 tracks this work item.
* Once this bug is fixed, the framework should fail registration
* for a driver that does not implement this entry point and
* assert ring->mr_stat != NULL here.
*/
return (val);
}
static int
{
}
static void
const char *statname)
{
}
/*
* Per tx ring statistics
*/
{
/*
* XXX Every ring-capable driver must implement an entry point to
* query per ring statistics. CR 6893122 tracks this work item.
* Once this bug is fixed, the framework should fail registration
* for a driver that does not implement this entry point and
* assert ring->mr_stat != NULL here.
*/
return (val);
}
static int
{
}
static void
const char *statname)
{
}
/*
* Per software lane tx statistics
*/
static uint64_t
{
switch (stat) {
case MAC_STAT_OBYTES:
return (mac_tx_stat->mts_obytes);
case MAC_STAT_OPACKETS:
return (mac_tx_stat->mts_opackets);
case MAC_STAT_OERRORS:
return (mac_tx_stat->mts_oerrors);
case MAC_STAT_BLOCK:
return (mac_tx_stat->mts_blockcnt);
case MAC_STAT_UNBLOCK:
return (mac_tx_stat->mts_unblockcnt);
case MAC_STAT_TXSDROPS:
return (mac_tx_stat->mts_sdrops);
default:
return (0);
}
}
static int
{
}
static void
const char *statname)
{
}
/*
* Per software lane rx statistics
*/
static uint64_t
{
switch (stat) {
case MAC_STAT_IPACKETS:
return (mac_rx_stat->mrs_intrcnt +
case MAC_STAT_RBYTES:
return (mac_rx_stat->mrs_intrbytes +
case MAC_STAT_LCL:
return (mac_rx_stat->mrs_lclcnt);
case MAC_STAT_LCLBYTES:
return (mac_rx_stat->mrs_lclbytes);
case MAC_STAT_INTRS:
return (mac_rx_stat->mrs_intrcnt);
case MAC_STAT_INTRBYTES:
return (mac_rx_stat->mrs_intrbytes);
case MAC_STAT_RXSDROPS:
return (mac_rx_stat->mrs_sdrops);
default:
return (0);
}
}
static int
{
}
static void
const char *statname)
{
}
/*
* Per hardware lane rx statistics
*/
static uint64_t
{
switch (stat) {
case MAC_STAT_IPACKETS:
return (mac_rx_stat->mrs_intrcnt +
case MAC_STAT_RBYTES:
return (mac_rx_stat->mrs_intrbytes +
case MAC_STAT_INTRS:
return (mac_rx_stat->mrs_intrcnt);
case MAC_STAT_INTRBYTES:
return (mac_rx_stat->mrs_intrbytes);
case MAC_STAT_POLLS:
return (mac_rx_stat->mrs_pollcnt);
case MAC_STAT_POLLBYTES:
return (mac_rx_stat->mrs_pollbytes);
case MAC_STAT_RXSDROPS:
return (mac_rx_stat->mrs_sdrops);
case MAC_STAT_CHU10:
return (mac_rx_stat->mrs_chaincntundr10);
case MAC_STAT_CH10T50:
return (mac_rx_stat->mrs_chaincnt10to50);
case MAC_STAT_CHO50:
return (mac_rx_stat->mrs_chaincntover50);
default:
return (0);
}
}
static int
{
}
static void
const char *statname)
{
}
/*
* Misc statistics
*
* Counts for
* - Tx errors
*/
static uint64_t
{
switch (stat) {
case MAC_STAT_MULTIRCV:
return (mac_misc_stat->mms_multircv);
case MAC_STAT_BRDCSTRCV:
return (mac_misc_stat->mms_brdcstrcv);
case MAC_STAT_MULTIXMT:
return (mac_misc_stat->mms_multixmt);
case MAC_STAT_BRDCSTXMT:
return (mac_misc_stat->mms_brdcstxmt);
case MAC_STAT_MULTIRCVBYTES:
return (mac_misc_stat->mms_multircvbytes);
case MAC_STAT_BRDCSTRCVBYTES:
return (mac_misc_stat->mms_brdcstrcvbytes);
case MAC_STAT_MULTIXMTBYTES:
return (mac_misc_stat->mms_multixmtbytes);
case MAC_STAT_BRDCSTXMTBYTES:
return (mac_misc_stat->mms_brdcstxmtbytes);
case MAC_STAT_TX_ERRORS:
return (mac_misc_stat->mms_txerrors);
case MAC_STAT_MACSPOOFED:
return (mac_misc_stat->mms_macspoofed);
case MAC_STAT_IPSPOOFED:
return (mac_misc_stat->mms_ipspoofed);
case MAC_STAT_DHCPSPOOFED:
return (mac_misc_stat->mms_dhcpspoofed);
case MAC_STAT_RESTRICTED:
return (mac_misc_stat->mms_restricted);
case MAC_STAT_DHCPDROPPED:
return (mac_misc_stat->mms_dhcpdropped);
case MAC_STAT_IPACKETS:
return (mac_rx_stat->mrs_intrcnt +
case MAC_STAT_RBYTES:
return (mac_rx_stat->mrs_intrbytes +
case MAC_STAT_LCL:
return (mac_rx_stat->mrs_lclcnt);
case MAC_STAT_LCLBYTES:
return (mac_rx_stat->mrs_lclbytes);
case MAC_STAT_INTRS:
return (mac_rx_stat->mrs_intrcnt);
case MAC_STAT_INTRBYTES:
return (mac_rx_stat->mrs_intrbytes);
case MAC_STAT_POLLS:
return (mac_rx_stat->mrs_pollcnt);
case MAC_STAT_POLLBYTES:
return (mac_rx_stat->mrs_pollbytes);
case MAC_STAT_RXSDROPS:
return (mac_rx_stat->mrs_sdrops);
case MAC_STAT_CHU10:
return (mac_rx_stat->mrs_chaincntundr10);
case MAC_STAT_CH10T50:
return (mac_rx_stat->mrs_chaincnt10to50);
case MAC_STAT_CHO50:
return (mac_rx_stat->mrs_chaincntover50);
case MAC_STAT_OBYTES:
return (mac_tx_stat->mts_obytes);
case MAC_STAT_OPACKETS:
return (mac_tx_stat->mts_opackets);
case MAC_STAT_OERRORS:
return (mac_tx_stat->mts_oerrors);
case MAC_STAT_BLOCK:
return (mac_tx_stat->mts_blockcnt);
case MAC_STAT_UNBLOCK:
return (mac_tx_stat->mts_unblockcnt);
case MAC_STAT_TXSDROPS:
return (mac_tx_stat->mts_sdrops);
default:
return (0);
}
}
static int
{
}
static void
const char *statname)
{
}
/*
* Per hardware lane tx statistics
*/
static uint64_t
{
switch (stat) {
case MAC_STAT_OBYTES:
return (mac_tx_stat->mts_obytes);
case MAC_STAT_OPACKETS:
return (mac_tx_stat->mts_opackets);
case MAC_STAT_OERRORS:
return (mac_tx_stat->mts_oerrors);
case MAC_STAT_BLOCK:
return (mac_tx_stat->mts_blockcnt);
case MAC_STAT_UNBLOCK:
return (mac_tx_stat->mts_unblockcnt);
case MAC_STAT_TXSDROPS:
return (mac_tx_stat->mts_sdrops);
default:
return (0);
}
}
static int
{
}
static void
const char *statname)
{
}
/*
* Per fanout rx statistics
*/
static uint64_t
{
int index;
/* Extract corresponding udp and oth ring pointers */
break;
}
}
switch (stat) {
case MAC_STAT_RBYTES:
break;
case MAC_STAT_IPACKETS:
break;
default:
val = 0;
break;
}
return (val);
}
static int
{
}
static void
const char *statname)
{
}
/*
* Exported functions.
*/
/*
* Create the "mac" kstat. The "mac" kstat is comprised of three kinds of
* statistics: statistics maintained by the mac module itself, generic mac
* statistics maintained by the driver, and MAC-type specific statistics
* also maintained by the driver.
*/
void
{
return;
knp += MAC_MOD_NKSTAT;
knp += MAC_NKSTAT;
}
}
/*ARGSUSED*/
void
{
mip->mi_kstat_count = 0;
}
}
{
if (IS_MAC_STAT(stat)) {
}
}
void
{
} else
case MAC_RING_TYPE_RX:
break;
case MAC_RING_TYPE_TX:
break;
default:
break;
}
}
void
{
return;
if (is_tx_srs) {
} else {
"mac_tx_swlane0");
}
statname);
} else {
"mac_rx_swlane0");
} else {
}
}
}
void
{
return;
}
void
{
return;
if (is_tx_srs) { /* tx side hardware lane */
statname);
} else { /* rx side fanout */
/* Maintain single stat for (tcp, udp, oth) */
int index;
break;
}
} else {
"mac_rx_hwlane%d_fanout%d",
}
statname);
}
}
}
void
{
}
}
void
{
if (!is_tx_srs) {
/*
* Rx ring has been taken away. Before destroying corresponding
* SRS, save the stats recorded by that SRS.
*/
}
}
}
void
{
}
}
void
{
if (is_tx_srs) {
/*
* Tx ring has been taken away. Before destroying corresponding
* soft ring, save the stats recorded by that soft ring.
*/
}
if (ringp->s_ring_ksp) {
}
}
void
{
/* Recreate pseudo rx ring kstats */
}
}
/* Recreate pseudo tx ring kstats */
}
}
}
void
{
int i, j;
/* Recreate rx SRSes kstats */
for (i = 0; i < flent->fe_rx_srs_cnt; i++) {
/* Recreate rx fanout kstats */
for (j = 0; j < mac_srs->srs_tcp_ring_count; j++) {
}
}
/* Recreate tx SRS kstats */
/* Recreate tx sofring kstats */
}
/* Recreate misc kstats */
}
void
{
if (add_stats) {
/* Add the stats to cumulative stats */
}
}