|
|
|
|
@ -21,6 +21,141 @@
|
|
|
|
|
|
|
|
|
|
static SCPerfOPIfaceContext *sc_perf_op_ctx = NULL;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Increments the local counter
|
|
|
|
|
*
|
|
|
|
|
* \param id Index of the counter in the counter array
|
|
|
|
|
* \param pca Counter array that holds the local counters for this TM
|
|
|
|
|
*/
|
|
|
|
|
void SCPerfCounterIncr(uint16_t id, SCPerfCounterArray *pca)
|
|
|
|
|
{
|
|
|
|
|
if (pca == NULL) {
|
|
|
|
|
SCLogDebug("counterarray is NULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((id < 1) || (id > pca->size)) {
|
|
|
|
|
SCLogDebug("counter doesn't exist");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (pca->head[id].pc->value->type) {
|
|
|
|
|
case SC_PERF_TYPE_UINT64:
|
|
|
|
|
pca->head[id].ui64_cnt++;
|
|
|
|
|
break;
|
|
|
|
|
case SC_PERF_TYPE_DOUBLE:
|
|
|
|
|
pca->head[id].d_cnt++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pca->head[id].syncs == ULONG_MAX) {
|
|
|
|
|
pca->head[id].syncs = 0;
|
|
|
|
|
pca->head[id].wrapped_syncs++;
|
|
|
|
|
}
|
|
|
|
|
pca->head[id].syncs++;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Sets a value of type double to the local counter
|
|
|
|
|
*
|
|
|
|
|
* \param id Index of the local counter in the counter array
|
|
|
|
|
* \param pca Pointer to the SCPerfCounterArray
|
|
|
|
|
* \param x The value to set for the counter
|
|
|
|
|
*/
|
|
|
|
|
void SCPerfCounterSetUI64(uint16_t id, SCPerfCounterArray *pca,
|
|
|
|
|
uint64_t x)
|
|
|
|
|
{
|
|
|
|
|
if (!pca) {
|
|
|
|
|
SCLogDebug("counterarray is NULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((id < 1) || (id > pca->size)) {
|
|
|
|
|
SCLogDebug("counter doesn't exist");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (pca->head[id].pc->value->type) {
|
|
|
|
|
case SC_PERF_TYPE_UINT64:
|
|
|
|
|
if ( (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_MAXIMUM) &&
|
|
|
|
|
(x > pca->head[id].ui64_cnt)) {
|
|
|
|
|
pca->head[id].ui64_cnt = x;
|
|
|
|
|
} else if (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_NORMAL) {
|
|
|
|
|
pca->head[id].ui64_cnt = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case SC_PERF_TYPE_DOUBLE:
|
|
|
|
|
if ( (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_MAXIMUM) &&
|
|
|
|
|
(x > pca->head[id].d_cnt)) {
|
|
|
|
|
pca->head[id].d_cnt = x;
|
|
|
|
|
} else if (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_NORMAL) {
|
|
|
|
|
pca->head[id].d_cnt = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pca->head[id].syncs == ULONG_MAX) {
|
|
|
|
|
pca->head[id].syncs = 0;
|
|
|
|
|
pca->head[id].wrapped_syncs++;
|
|
|
|
|
}
|
|
|
|
|
pca->head[id].syncs++;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Sets a local counter to an arg of type double
|
|
|
|
|
*
|
|
|
|
|
* \param id Index of the local counter in the counter array
|
|
|
|
|
* \param pca Pointer to the SCPerfCounterArray
|
|
|
|
|
* \param x The value to set for the counter
|
|
|
|
|
*/
|
|
|
|
|
void SCPerfCounterSetDouble(uint16_t id, SCPerfCounterArray *pca,
|
|
|
|
|
double x)
|
|
|
|
|
{
|
|
|
|
|
if (!pca) {
|
|
|
|
|
SCLogDebug("counterarray is NULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((id < 1) || (id > pca->size)) {
|
|
|
|
|
SCLogDebug("counter doesn't exist");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (pca->head[id].pc->value->type) {
|
|
|
|
|
case SC_PERF_TYPE_UINT64:
|
|
|
|
|
if ( (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_MAXIMUM) &&
|
|
|
|
|
(x > pca->head[id].ui64_cnt)) {
|
|
|
|
|
pca->head[id].ui64_cnt = x;
|
|
|
|
|
} else if (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_NORMAL) {
|
|
|
|
|
pca->head[id].ui64_cnt = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case SC_PERF_TYPE_DOUBLE:
|
|
|
|
|
if ( (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_MAXIMUM) &&
|
|
|
|
|
(x > pca->head[id].d_cnt)) {
|
|
|
|
|
pca->head[id].d_cnt = x;
|
|
|
|
|
} else if (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_NORMAL) {
|
|
|
|
|
pca->head[id].d_cnt = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pca->head[id].syncs == ULONG_MAX) {
|
|
|
|
|
pca->head[id].syncs = 0;
|
|
|
|
|
pca->head[id].wrapped_syncs++;
|
|
|
|
|
}
|
|
|
|
|
pca->head[id].syncs++;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Get the filename with path to the stats log file.
|
|
|
|
|
*
|
|
|
|
|
@ -1292,215 +1427,6 @@ int SCPerfCounterDisplay(uint16_t id, SCPerfContext *pctx, int disp)
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Increments the local counter
|
|
|
|
|
*
|
|
|
|
|
* \param id Index of the counter in the counter array
|
|
|
|
|
* \param pca Counter array that holds the local counters for this TM
|
|
|
|
|
*/
|
|
|
|
|
inline void SCPerfCounterIncr(uint16_t id, SCPerfCounterArray *pca)
|
|
|
|
|
{
|
|
|
|
|
if (pca == NULL) {
|
|
|
|
|
SCLogDebug("counterarray is NULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((id < 1) || (id > pca->size)) {
|
|
|
|
|
SCLogDebug("counter doesn't exist");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (pca->head[id].pc->value->type) {
|
|
|
|
|
case SC_PERF_TYPE_UINT64:
|
|
|
|
|
pca->head[id].ui64_cnt++;
|
|
|
|
|
break;
|
|
|
|
|
case SC_PERF_TYPE_DOUBLE:
|
|
|
|
|
pca->head[id].d_cnt++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pca->head[id].syncs == ULONG_MAX) {
|
|
|
|
|
pca->head[id].syncs = 0;
|
|
|
|
|
pca->head[id].wrapped_syncs++;
|
|
|
|
|
}
|
|
|
|
|
pca->head[id].syncs++;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Adds a value of type uint64_t to the local counter.
|
|
|
|
|
*
|
|
|
|
|
* \param id ID of the counter as set by the API
|
|
|
|
|
* \param pca Counter array that holds the local counter for this TM
|
|
|
|
|
* \param x Value to add to this local counter
|
|
|
|
|
*/
|
|
|
|
|
inline void SCPerfCounterAddUI64(uint16_t id, SCPerfCounterArray *pca, uint64_t x)
|
|
|
|
|
{
|
|
|
|
|
if (!pca) {
|
|
|
|
|
SCLogDebug("counterarray is NULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((id < 1) || (id > pca->size)) {
|
|
|
|
|
SCLogDebug("counter doesn't exist");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (pca->head[id].pc->value->type) {
|
|
|
|
|
case SC_PERF_TYPE_UINT64:
|
|
|
|
|
pca->head[id].ui64_cnt += x;
|
|
|
|
|
break;
|
|
|
|
|
case SC_PERF_TYPE_DOUBLE:
|
|
|
|
|
pca->head[id].d_cnt += x;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pca->head[id].syncs == ULONG_MAX) {
|
|
|
|
|
pca->head[id].syncs = 0;
|
|
|
|
|
pca->head[id].wrapped_syncs++;
|
|
|
|
|
}
|
|
|
|
|
pca->head[id].syncs++;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Adds a value of type double to the local counter
|
|
|
|
|
*
|
|
|
|
|
* \param id ID of the counter as set by the API
|
|
|
|
|
* \param pca Counter array that holds the local counter for this TM
|
|
|
|
|
* \param x Value to add to this local counter
|
|
|
|
|
*/
|
|
|
|
|
inline void SCPerfCounterAddDouble(uint16_t id, SCPerfCounterArray *pca, double x)
|
|
|
|
|
{
|
|
|
|
|
if (!pca) {
|
|
|
|
|
SCLogDebug("counterarray is NULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((id < 1) || (id > pca->size)) {
|
|
|
|
|
SCLogDebug("counter doesn't exist");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* incase you are trying to add a double to a counter of type SC_PERF_TYPE_UINT64
|
|
|
|
|
* it will be truncated */
|
|
|
|
|
switch (pca->head[id].pc->value->type) {
|
|
|
|
|
case SC_PERF_TYPE_UINT64:
|
|
|
|
|
pca->head[id].ui64_cnt += x;
|
|
|
|
|
break;
|
|
|
|
|
case SC_PERF_TYPE_DOUBLE:
|
|
|
|
|
pca->head[id].d_cnt += x;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pca->head[id].syncs == ULONG_MAX) {
|
|
|
|
|
pca->head[id].syncs = 0;
|
|
|
|
|
pca->head[id].wrapped_syncs++;
|
|
|
|
|
}
|
|
|
|
|
pca->head[id].syncs++;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Sets a value of type double to the local counter
|
|
|
|
|
*
|
|
|
|
|
* \param id Index of the local counter in the counter array
|
|
|
|
|
* \param pca Pointer to the SCPerfCounterArray
|
|
|
|
|
* \param x The value to set for the counter
|
|
|
|
|
*/
|
|
|
|
|
inline void SCPerfCounterSetUI64(uint16_t id, SCPerfCounterArray *pca,
|
|
|
|
|
uint64_t x)
|
|
|
|
|
{
|
|
|
|
|
if (!pca) {
|
|
|
|
|
SCLogDebug("counterarray is NULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((id < 1) || (id > pca->size)) {
|
|
|
|
|
SCLogDebug("counter doesn't exist");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (pca->head[id].pc->value->type) {
|
|
|
|
|
case SC_PERF_TYPE_UINT64:
|
|
|
|
|
if ( (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_MAXIMUM) &&
|
|
|
|
|
(x > pca->head[id].ui64_cnt)) {
|
|
|
|
|
pca->head[id].ui64_cnt = x;
|
|
|
|
|
} else if (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_NORMAL) {
|
|
|
|
|
pca->head[id].ui64_cnt = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case SC_PERF_TYPE_DOUBLE:
|
|
|
|
|
if ( (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_MAXIMUM) &&
|
|
|
|
|
(x > pca->head[id].d_cnt)) {
|
|
|
|
|
pca->head[id].d_cnt = x;
|
|
|
|
|
} else if (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_NORMAL) {
|
|
|
|
|
pca->head[id].d_cnt = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pca->head[id].syncs == ULONG_MAX) {
|
|
|
|
|
pca->head[id].syncs = 0;
|
|
|
|
|
pca->head[id].wrapped_syncs++;
|
|
|
|
|
}
|
|
|
|
|
pca->head[id].syncs++;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Sets a local counter to an arg of type double
|
|
|
|
|
*
|
|
|
|
|
* \param id Index of the local counter in the counter array
|
|
|
|
|
* \param pca Pointer to the SCPerfCounterArray
|
|
|
|
|
* \param x The value to set for the counter
|
|
|
|
|
*/
|
|
|
|
|
inline void SCPerfCounterSetDouble(uint16_t id, SCPerfCounterArray *pca,
|
|
|
|
|
double x)
|
|
|
|
|
{
|
|
|
|
|
if (!pca) {
|
|
|
|
|
SCLogDebug("counterarray is NULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((id < 1) || (id > pca->size)) {
|
|
|
|
|
SCLogDebug("counter doesn't exist");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (pca->head[id].pc->value->type) {
|
|
|
|
|
case SC_PERF_TYPE_UINT64:
|
|
|
|
|
if ( (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_MAXIMUM) &&
|
|
|
|
|
(x > pca->head[id].ui64_cnt)) {
|
|
|
|
|
pca->head[id].ui64_cnt = x;
|
|
|
|
|
} else if (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_NORMAL) {
|
|
|
|
|
pca->head[id].ui64_cnt = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case SC_PERF_TYPE_DOUBLE:
|
|
|
|
|
if ( (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_MAXIMUM) &&
|
|
|
|
|
(x > pca->head[id].d_cnt)) {
|
|
|
|
|
pca->head[id].d_cnt = x;
|
|
|
|
|
} else if (pca->head[id].pc->type_q->type & SC_PERF_TYPE_Q_NORMAL) {
|
|
|
|
|
pca->head[id].d_cnt = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pca->head[id].syncs == ULONG_MAX) {
|
|
|
|
|
pca->head[id].syncs = 0;
|
|
|
|
|
pca->head[id].wrapped_syncs++;
|
|
|
|
|
}
|
|
|
|
|
pca->head[id].syncs++;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Syncs the counter array with the global counter variables
|
|
|
|
|
*
|
|
|
|
|
|