318 lines
11 KiB
C
318 lines
11 KiB
C
/****************************************************************
|
|
* *
|
|
* Copyright (C) 1991-2007 Celoxica Ltd. All rights reserved. *
|
|
* *
|
|
*****************************************************************
|
|
* *
|
|
* Project : Generic AMDC *
|
|
* Date : 08 MAY 2009 *
|
|
* File : gmac_stats.h *
|
|
* Author : Patrik Beck (PB) *
|
|
* Contributors: *
|
|
* *
|
|
* Description: *
|
|
* *
|
|
* Date Version Author Reason for change *
|
|
* 08 MAY 2009 1.00 PB Created *
|
|
* 26 NOV 2010 1.01 LM Everything now in GMAC_UserAPI *
|
|
* *
|
|
****************************************************************/
|
|
|
|
#ifndef __CELOXICA_GMAC_STATS_H__
|
|
#define __CELOXICA_GMAC_STATS_H__
|
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
|
#define __STDC_FORMAT_MACROS
|
|
#endif // __STDC_FORMAT_MACROS
|
|
|
|
#include "gmac.h"
|
|
#include "gmac_info.h"
|
|
#include <inttypes.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
|
|
/**
|
|
* \ingroup GMAC_UserAPI
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* \brief Returns pointer to live statistics of a particular multicast
|
|
*
|
|
* @param H GMAC Handle
|
|
* @param MulticastID MulticastID the statistics will be for
|
|
* @param Stats Pointer where statistics will be passed
|
|
* @return GMAC_STATUS_OK on suscess
|
|
*/
|
|
extern GMACStatus GMACStatsMulticast (GMACHandle *H, GMACMulticastID MulticastID, GMACStats **Stats);
|
|
|
|
/**
|
|
* \brief Returns pointer to live statistics of a particular channel
|
|
*
|
|
* Returns a pointer to live statistics of the channel specified by LocalChannelID.
|
|
*
|
|
* @param H GMAC Handle
|
|
* @param MarketID Market ID of the market the channel is openned for
|
|
* @param LocalChannelID Channel ID local to the market, the ID specified in the config file
|
|
* @param Stats Pointer where statistics will be passed
|
|
* @return GMAC_STATUS_OK on suscess
|
|
*/
|
|
extern GMACStatus GMACStatsChannel(GMACHandle *GMACH, int MarketID, int LocalChannelID, GMACStats **Stats);
|
|
|
|
/**
|
|
* \brief Returns global statistics
|
|
*
|
|
* The user can get a copy of the global statistics. Useful for monitoring all the multicast
|
|
* channels. The statistics are always representing the current state.
|
|
*
|
|
* Please note the function call does read registers of the card, which makes it slow to return. It should not be called from performance critical sections.
|
|
*
|
|
* @param H GMAC Handle
|
|
* @param Queue The queue number
|
|
* @param Stats Pointer where statistics will be passed
|
|
* @param PacketsMissed Packets dropped by the accelerator card, because software wasn't keeping up
|
|
* @param CRCErrors Packets dropped by the accelerator card, because of underlying protocol errors
|
|
* @return GMAC_STATUS_OK on successk
|
|
*/
|
|
extern GMACStatus GMACStatsQueueGlobal (GMACHandle *H, int Queue, GMACStats **Stats, uint64_t *PacketsMissed, uint64_t *CRCErrors);
|
|
|
|
|
|
|
|
/**
|
|
* \brief Returns number of open channels for specific market
|
|
*
|
|
* @param H GMAC Handle
|
|
* @param MarketID Market ID
|
|
* @param Count Channel count
|
|
* @return GMAC_STATUS_OK on suscess
|
|
*/
|
|
extern GMACStatus GMACStatsMarketChannelCount (GMACHandle *H, int MarketID, int *Count);
|
|
|
|
|
|
|
|
/**
|
|
* \brief Dumps the structure
|
|
*/
|
|
static inline void GMACStatsDump (GMACStats *Stats, FILE *f) {
|
|
fprintf(f, " Received total %10" PRIu64 "\n", Stats->PacketsReceivedTotal);
|
|
|
|
if (Stats->PacketsReceivedADE)
|
|
fprintf(f, " (Received ADE) %10" PRIu64 "\n", Stats->PacketsReceivedADE);
|
|
|
|
if (Stats->PacketsReceivedTimeout)
|
|
fprintf(f, " (Received Timeouts) %10" PRIu64 "\n", Stats->PacketsReceivedTimeout);
|
|
|
|
if (Stats->PacketsDelivered || Stats->PacketsReceivedTotal)
|
|
fprintf(f, " Delivered %10" PRIu64 "\n", Stats->PacketsDelivered);
|
|
|
|
if (Stats->PacketsInReorderQueue)
|
|
fprintf(f, " In reorder queue %10" PRIu64 "\n", Stats->PacketsInReorderQueue);
|
|
|
|
if (Stats->PacketsReceivedControl)
|
|
fprintf(f, " Received control queue %10" PRIu64 "\n", Stats->PacketsReceivedControl);
|
|
|
|
if (Stats->PacketsReceivedRedirected)
|
|
fprintf(f, " Received redirected %10" PRIu64 "\n", Stats->PacketsReceivedRedirected);
|
|
|
|
if (Stats->PacketsDroppedPayloadError)
|
|
fprintf(f, " Dropped as payload error %10" PRIu64 "\n", Stats->PacketsDroppedPayloadError);
|
|
|
|
if (Stats->PacketsDroppedInTranscoder)
|
|
fprintf(f, " Dropped by transcoder %10" PRIu64 "\n", Stats->PacketsDroppedInTranscoder);
|
|
|
|
if (Stats->PacketsDroppedSimulated)
|
|
fprintf(f, " Dropped for gap simulation %10" PRIu64 "\n", Stats->PacketsDroppedSimulated);
|
|
|
|
if (Stats->PacketsDroppedAsDuplicates)
|
|
fprintf(f, " Dropped as duplicates %10" PRIu64 "\n", Stats->PacketsDroppedAsDuplicates);
|
|
|
|
if (Stats->PacketsDroppedInReorderQueue)
|
|
fprintf(f, " Dropped in reorder queue %10" PRIu64 "\n", Stats->PacketsDroppedInReorderQueue);
|
|
|
|
if (Stats->ExpectedSequenceNumber != SEQUENCE_UNDEFINED)
|
|
{
|
|
fprintf(f, " Expected sequence number %10" PRIu64 "\n", Stats->ExpectedSequenceNumber);
|
|
}
|
|
|
|
if (Stats->GapsDetected || Stats->GapsPassed)
|
|
{
|
|
fprintf(f, " Gaps detected %10" PRIu64 "\n", Stats->GapsDetected);
|
|
fprintf(f, " Gaps passed %10" PRIu64 "\n", Stats->GapsPassed);
|
|
}
|
|
|
|
int64_t Difference = Stats->PacketsReceivedTotal;
|
|
Difference += Stats->PacketsReceivedControl;
|
|
Difference -= Stats->PacketsDelivered;
|
|
Difference -= Stats->PacketsInReorderQueue;
|
|
Difference -= Stats->PacketsDroppedPayloadError;
|
|
Difference -= Stats->PacketsDroppedInTranscoder;
|
|
Difference -= Stats->PacketsDroppedSimulated;
|
|
Difference -= Stats->PacketsDroppedAsDuplicates;
|
|
Difference -= Stats->PacketsDroppedInReorderQueue;
|
|
|
|
if (Difference)
|
|
{
|
|
fprintf (f, " Difference %10" PRIi64 "\n", Difference);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* \brief Prints statistics of a multicast into the stream
|
|
*
|
|
* @param H GMAC Handle
|
|
* @param MulticastID The statistics to print
|
|
* @param f stream to print to
|
|
*/
|
|
static inline void GMACStatsMulticastPrint (GMACHandle *H, int Queue, GMACMulticastID MulticastID, FILE *f) {
|
|
|
|
GMACStats *Stats;
|
|
|
|
//fprintf(f, "ChannelID: %" PRIu64 "%s%s\n", (uint64_t)ChannelID, (Market[0] != '\0' ? " Market: " : ""), Market);
|
|
|
|
if (GMACStatsMulticast(H, MulticastID, &Stats) == GMAC_STATUS_OK) {
|
|
|
|
const char *MarketName = "";
|
|
uint32_t MarketIndex = ~0U;
|
|
GMACGetObjProps(H, GMAC_OBJ_SRC_CHANNEL, MulticastID, GMAC_PROP_MARKET_NAME, &MarketName,
|
|
GMAC_PROP_MARKET_ID, &MarketIndex, NULL);
|
|
|
|
fprintf(f, "Queue %d", Queue);
|
|
fprintf(f, " multicast %d", (int) Stats->MulticastID);
|
|
fprintf(f, " channel %d", (int) Stats->ChannelID);
|
|
fprintf(f, " local %d/'%c'", (int) Stats->LocalChannelID, Stats->LocalChannelChar);
|
|
fprintf(f, " plugin %s", Stats->AdePlugin);
|
|
fprintf(f, " market %u/%s", MarketIndex, MarketIndex == ~0U ? "?" : MarketName);
|
|
fprintf(f, " type %s", GMACMulticastTypeToString(Stats->Type));
|
|
if (~Stats->RedirectedToID) fprintf(f, " redirected_to %d", (int) Stats->RedirectedToID);
|
|
if (~Stats->MultiContextRef) fprintf(f, " MultiContextRef %d", (int)Stats->MultiContextRef);
|
|
if (Stats->IsMultiContext) fprintf (f, " MultiContext");
|
|
if (Stats->Buffered) fprintf (f, " Buffered");
|
|
if (Stats->Disabled) fprintf (f, " Disabled");
|
|
if (Stats->IgnoreGaps) fprintf (f, " IgnoreGaps");
|
|
if (Stats->ExpectRepackaged) fprintf (f, " ExpectRepackaged");
|
|
if (Stats->FilteringModuleInUse)
|
|
{
|
|
if (Stats->FilteringEnabled)
|
|
{
|
|
fprintf(f, " Filtered");
|
|
}
|
|
else
|
|
{
|
|
fprintf(f, " Unfiltered");
|
|
}
|
|
}
|
|
fprintf(f, "\n");
|
|
|
|
GMACStatsDump(Stats, f);
|
|
}
|
|
else
|
|
{
|
|
fprintf (f, "Multicast %d closed\n", (int) MulticastID);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* \brief Prints statistics
|
|
*
|
|
* @param H GMAC Handle
|
|
* @param Str String to print
|
|
* @param f Target stream
|
|
*/
|
|
static void GMACStatsMulticastPrintStr (char *Str, FILE *f)
|
|
{
|
|
fprintf (f, "%s", Str);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* \brief Prints All channels using supplied function
|
|
*/
|
|
extern void __GMACStatsAllMulticastPrint(GMACHandle *H, int Queue, FILE *f, void (*Fnc)(GMACHandle *H, int Queue, GMACChannelID ChannelID, FILE *f));
|
|
|
|
/**
|
|
* \brief Prints All channels using supplied function (next expected sqn)
|
|
*/
|
|
extern void __GMACStatsAllMulticastPrintSqn (GMACHandle *H, FILE *f, void (*Fnc)(char *Str, FILE *f));
|
|
|
|
|
|
/**
|
|
* \brief Prints statistics for next expected sequence
|
|
*
|
|
* @param H GMAC Handle
|
|
* @param f stream to print to
|
|
*/
|
|
static inline void GMACStatsPrintSqn (GMACHandle *H, FILE *f)
|
|
{
|
|
__GMACStatsAllMulticastPrintSqn (H, f, &GMACStatsMulticastPrintStr);
|
|
}
|
|
|
|
/**
|
|
* \brief Prints statistics into the stream
|
|
*
|
|
* @param H GMAC Handle
|
|
* @param f stream to print to
|
|
*/
|
|
static inline void GMACStatsPrint (GMACHandle *H, int Queue, FILE *f) {
|
|
__GMACStatsAllMulticastPrint(H, Queue, f, &GMACStatsMulticastPrint);
|
|
|
|
//global stats
|
|
GMACStats *Stats = NULL;
|
|
uint64_t PacketsMissed;
|
|
uint64_t CRCErrors;
|
|
|
|
GMACStatus st = GMACStatsQueueGlobal (H, Queue, &Stats, &PacketsMissed, &CRCErrors);
|
|
|
|
if (st != GMAC_STATUS_OK)
|
|
{
|
|
fprintf (stderr, "GMACStatsPrint(): error: %d (%s)\n", st, GMACStatusToString(st));
|
|
}
|
|
|
|
fprintf(f, "GMAC global statistics for queue %d:\n", Queue);
|
|
|
|
GMACStatsDump(Stats, f);
|
|
|
|
fprintf(f, "GMAC ingress statistics for queue %d:\n", Queue);
|
|
fprintf(f, " Missed packets: %10" PRIu64 "\n", PacketsMissed);
|
|
fprintf(f, " FCS errors: %10" PRIu64 "\n", CRCErrors);
|
|
}
|
|
|
|
/**
|
|
* \brief Debug function to query the status of the DMA queue
|
|
*
|
|
* This is a debug function that can be used to query the amount of free space in the DMA queue.
|
|
* It can be useful during integration development, to ascertain whether the user code is processing
|
|
* incoming packets quickly enough and thus not falling behind and causing the DMA queue to fill up.
|
|
* This function call will affect latency and should therefore not be used in perfomance threads.
|
|
* This function is only available for the "lldt" plugin (i.e. for data streams eminating from
|
|
* accelerator cards).
|
|
*
|
|
* @param GMACH GMAC Handle
|
|
* @param Queue GMAC queue number
|
|
* @param BoardIndex Board index number. If set to -1, the first board on the queue is selected.
|
|
* @param CreditAvail Available DMA credit in bytes
|
|
* @param CreditMax Maximum amount of credit for the given DMA buffer; i.e. the size of the DMA buffer.
|
|
* @return GMAC_STATUS_OK on success
|
|
*/
|
|
extern GMACStatus GMACStatsGetCredit (GMACHandle *H, char *Plugin, int Queue, int BoardIndex, uint64_t *CreditAvail, uint64_t *CreditMax);
|
|
|
|
|
|
|
|
/**
|
|
* @}
|
|
* // End of GMACUserAPI group
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#endif
|
|
|