/*
 *               Copyright (C) 2006, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */

#ifndef __NC_PERF_H_
#define __NC_PERF_H_

#include <sc/iostypes.h>

/* system timer tick = 200 * system clock ticks
 *                   = 200 / system clock freq
 *                   = 200/100.8MHz
 *                   = 1984.1ns
 * system timer ticks/msec = 1 tick/1984.1ns
 *                         = 504000 tick/sec
 *                         = 504 tick/msec
 */
#define PERF_TICKS_PER_MSEC 504


typedef struct perfInfo_st {
    u32 start;       /* timer count value at beginning of interval */
    u32 stop;        /* timer count value at end of interval */
    u32 min;         /* minimum timed interval */
    u32 max;         /* maximum timed interval */
    u32 min_count;   /* interval number when minimum time interval occurred */
    u32 max_count;   /* interval number when maximum time interval occurred */
    u64 sum;         /* sum of all interval times */
    u32 avg;         /* average timed interval */
    u32 count;       /* number of intervals timed */
    char name[30];   /* user-supplied name of this instance */
} PerfInfo;

void perfInit(PerfInfo *pi, char *name);
void perfReset(PerfInfo *pi);
u32 perfStart(PerfInfo *pi);
u32 perfStop(PerfInfo *pi);
u32 perfAvg(PerfInfo *pi);
u32 perfMax(PerfInfo *pi);
u32 perfMin(PerfInfo *pi);
u32 perfCount(PerfInfo *pi);
void perfPrint(PerfInfo *pi);

#endif
