xgehal-stats.c revision a23fd118e437af0a7877dd313db8fdaa3537c675
/*
* 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 (c) 2002-2005 Neterion, Inc.
* All right Reserved.
*
* FileName : xgehal-stats.c
*
* Description: statistics object implementation
*
* Created: 2 June 2004
*/
#include "xgehal-stats.h"
#include "xgehal-device.h"
/*
* __hal_stats_initialize
* @stats: xge_hal_stats_t structure that contains, in particular,
* Xframe hw stat counters.
* @devh: HAL device handle.
*
* Initialize per-device statistics object.
* See also: xge_hal_stats_getinfo(), xge_hal_status_e{}.
*/
{
int dma_flags;
#ifdef XGE_HAL_DMA_STATS_CONSISTENT
#else
#endif
sizeof(xge_hal_stats_hw_info_t),
return XGE_HAL_ERR_OUT_OF_MEMORY;
}
sizeof(xge_hal_stats_hw_info_t),
#ifdef XGE_HAL_DMA_STATS_CONSISTENT
#else
#endif
);
sizeof(xge_hal_stats_hw_info_t),
&stats->hw_info_dmah);
return XGE_HAL_ERR_OUT_OF_MAPPING;
}
sizeof(xge_hal_stats_device_info_t));
return XGE_HAL_OK;
}
static void
{
sizeof(xge_hal_stats_hw_info_t));
}
/*
* __hal_stats_disable
* @stats: xge_hal_stats_t structure that contains, in particular,
* Xframe hw stat counters.
*
* Ask device to stop collecting stats.
* See also: xge_hal_stats_getinfo().
*/
void
{
/* flush the write */
stats->is_enabled = 0;
}
/*
* __hal_stats_terminate
* @stats: xge_hal_stats_t structure that contains, in particular,
* Xframe hw stat counters.
* Terminate per-device statistics object.
*/
void
{
sizeof(xge_hal_stats_hw_info_t),
sizeof(xge_hal_stats_hw_info_t),
&stats->hw_info_dmah);
stats->is_initialized = 0;
stats->is_enabled = 0;
}
/*
* __hal_stats_enable
* @stats: xge_hal_stats_t structure that contains, in particular,
* Xframe hw stat counters.
*
* Ask device to start collecting stats.
* See also: xge_hal_stats_getinfo().
*/
void
{
unsigned int refresh_time_pci_clocks;
/* enable statistics */
#ifdef XGE_HAL_HERC_EMULATION
/*
* The clocks in the emulator are running ~1000 times slower than real world,
* so the stats transfer will occur ~1000 times less frequent.
* STAT_CFG.STAT_TRSF_PERIOD should be set to 0x20C for Hercules emulation
* (stats transferred every 0.5 sec).
*/
#else
#endif
}
/*
* __hal_stats_update_latest - Update hw stats counters, based on the real
* hardware maintained counters and the stored "reset" values.
*/
static void
{
/* Tx MAC statistics counters. */
/* Rx MAC Statistics counters. */
/* DMA Transaction statistics. */
/* Enhanced Herc statistics */
}
/**
* xge_hal_stats_hw - Get HW device statistics.
* @devh: HAL device handle.
* @hw_info: Xframe statistic counters. See xge_hal_stats_hw_info_t.
* Returned by HAL.
*
* Get device and HAL statistics. The latter is part of the in-host statistics
* that HAL maintains for _that_ device.
*
* Returns: XGE_HAL_OK - success.
* XGE_HAL_INF_STATS_IS_NOT_READY - Statistics information is not
* currently available.
*
* See also: xge_hal_status_e{}.
*/
{
return XGE_HAL_INF_STATS_IS_NOT_READY;
}
#if defined(XGE_OS_DMA_REQUIRES_SYNC) && defined(XGE_HAL_DMA_STATS_STREAMING)
0,
sizeof(xge_hal_stats_hw_info_t),
#endif
/*
* update hw counters, taking into account
* the "reset" or "saved"
* values
*/
return XGE_HAL_OK;
}
/**
* xge_hal_stats_device - Get HAL statistics.
* @devh: HAL device handle.
* @hw_info: Xframe statistic counters. See xge_hal_stats_hw_info_t.
* Returned by HAL.
* @device_info: HAL statistics. See xge_hal_stats_device_info_t.
* Returned by HAL.
*
* Get device and HAL statistics. The latter is part of the in-host statistics
* that HAL maintains for _that_ device.
*
* Returns: XGE_HAL_OK - success.
* XGE_HAL_INF_STATS_IS_NOT_READY - Statistics information is not
* currently available.
*
* See also: xge_hal_status_e{}.
*/
{
*device_info = NULL;
return XGE_HAL_INF_STATS_IS_NOT_READY;
}
return XGE_HAL_OK;
}
/**
* xge_hal_stats_channel - Get channel statistics.
* @channelh: Channel handle.
* @channel_info: HAL channel statistic counters.
* See xge_hal_stats_channel_info_t{}. Returned by HAL.
*
* Retrieve statistics of a particular HAL channel. This includes, for instance,
* number of completions per interrupt, number of traffic interrupts, etc.
*
* Returns: XGE_HAL_OK - success.
* XGE_HAL_INF_STATS_IS_NOT_READY - Statistics information is not
* currently available.
*
* See also: xge_hal_status_e{}.
*/
{
return XGE_HAL_ERR_INVALID_DEVICE;
}
return XGE_HAL_ERR_INVALID_DEVICE;
}
*channel_info = NULL;
return XGE_HAL_INF_STATS_IS_NOT_READY;
}
/* to not confuse user */
}
}
#ifdef XGE_OS_PLATFORM_64BIT
}
#endif
}
#ifdef XGE_OS_PLATFORM_64BIT
}
#endif
return XGE_HAL_OK;
}
/**
* xge_hal_stats_reset - Reset (zero-out) device statistics
* @devh: HAL device handle.
*
* Reset all device statistics.
* Returns: XGE_HAL_OK - success.
* XGE_HAL_INF_STATS_IS_NOT_READY - Statistics information is not
* currently available.
*
* See also: xge_hal_status_e{}, xge_hal_stats_channel_info_t{},
* xge_hal_stats_sw_err_t{}, xge_hal_stats_device_info_t{}.
*/
{
return XGE_HAL_INF_STATS_IS_NOT_READY;
}
/* save hw stats to calculate the after-reset values */
/* zero-out driver-maintained stats, don't reset the saved */
return XGE_HAL_OK;
}
/*
* __hal_stats_soft_reset - Reset software-maintained statistics.
*/
void
{
if (reset_all) {
sizeof(xge_hal_stats_hw_info_t));
sizeof(xge_hal_stats_hw_info_t));
}
/* Reset the "soft" error and informational statistics */
sizeof(xge_hal_stats_sw_err_t));
sizeof(xge_hal_stats_device_info_t));
/* for each Rx channel */
sizeof(xge_hal_stats_channel_info_t));
}
/* for each Tx channel */
sizeof(xge_hal_stats_channel_info_t));
}
}