GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > EFC / V4-2-2

Constituent: efc     Tag: linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

EFS.c File Reference

Event Filter Statistics, Generic. More...

#include "EFC/EFS.h"
#include "EFC/EFC.h"
#include "EFC/EFA_def.h"
#include "EFC/EFS_ids.h"
#include "EFC/EFS_ctxCtb.h"
#include "EFC_time.ih"
#include "dprintf.h"
#include "EDS/FFS.h"
#include "EDS/EBF_gem.h"
#include "EMP/LSD_sdi.h"
#include "LSE/LSEW_ctxTim.h"
#include "EFC_DB/EFC_DB_schemaAnalysis.h"
#include "LSF/LSF.h"
#include "LSF/LSF_ids.h"
#include "LSF/LSF_cpu.h"
#include "LSF/LSF_origin.h"
#include "LSF/LSF_reason.h"
#include "LDT/BFP.h"
#include "PBS/PBS.h"
#include "PBS/FPA.h"
#include "PBS/SEM.h"
#include "PBS/FORK.h"
#include <string.h>

Include dependency graph for EFS.c:


Data Structures

struct  _EfsPrvHdr
 The previous last event header, used as the baseline for encoding the difference. More...
struct  _EFS_stats
 The statistics counters. More...
struct  _EFS_datagram
 Maps out the fixed part of an EFS datagram. More...
struct  _EFS
 The generic Event Filter Statistics utility handle. More...

Defines

#define ROUND(_val)   ((((int)(_val)) + 7) & ~(7))
#define NPACKETS   4
#define DATAGRAM_VERSION   0
#define CONTRIBUTION_VERSION   0
#define EFS_K_APID_BASE   0x3b7

Typedefs

typedef _EfsPrvHdr EfsPrvHdr
 Typedef for struct _EfsPrvHdr.
typedef _EFS_stats EFS_stats
 Typedef for struct _EFS_stats.
typedef _EFS_datagram EFS_datagram
 Typedef for struct EFS_datagram.
typedef _EFS EFS
 Typedef for struct _EFS.

Functions

static unsigned int sbsKeyGet (void)
 Retrieves the secondary boot script key.
static int get_datagram_size (int max_records)
 Computes, in bytes, the maximal size of a datagram of max_records.
static int get_datagram_pool_size (int max_records)
 Calculates the size in bytes of the ring buffer pool size from which the datagrams will be allocated.
static void accumulate (EFS_stats *stats, unsigned int stride, const void *beg, const void *end)
 Accumulates the event statistics for the results from beg to end.
static __inline unsigned int * copy (unsigned int *dst, const unsigned int *src, int nbytes)
 Copies the specified number of bytes.
static __inline void add (unsigned int *dst, const unsigned int *src, int cnt)
static unsigned int * format_hdr (unsigned int *dat, const EFA_hdr *hdr, const EfsPrvHdr *prv)
static unsigned int * format (unsigned int *dat, const unsigned int *buf, int n, unsigned int max)
 Encodes the input buffer using a significant bit count followed by the significant bits.
static unsigned int * format_stats (unsigned int *dat, const EFS_stats *stats)
 Format the statisitics buffer.
static unsigned int * format_diff_stats (unsigned int *dat, const EFS_stats *cur, const EFS_stats *prv)
 Format the statisitics buffer as the difference between the current and previous.
static LSF_record * format_global_record (LSF_record *rec, const EFA_span *span, const EFS_stats *stats)
 Formats the global statistics record.
static LSF_record * format_begin_record (LSF_record *rec, const EFA_span *span, const EFS_stats *stats)
 Formats a normal record with 2 headers.
static LSF_record * format_record (LSF_record *rec, const EFA_span *span, const EFS_stats *stats)
 Formats a standard statistics record with one header.
static LSF_record * format_diff_record (LSF_record *rec, const EfsPrvHdr *prv_hdr, const EFA_span *span, const EFS_stats *cur, const EFS_stats *prv)
 Formats a standard statistics record.
static __inline void clear (EFS *efs)
 Clears the statistics block.
static __inline void compose_ctx_template (EFS_ctxCtb *ctb, unsigned int sbs, unsigned int schema_key, LSF_CPU_K cpu, LSF_ORIGIN_K origin)
 Composes the static (one-time fill-in) fields of the context contribution.
unsigned char * EFS_construct (EFS *efs, const EFC_DB_SchemaAnalysis *schema, int result_size, unsigned int apid_offset, unsigned int dgmid_offset, LSF_CPU_K cpu, LSF_ORIGIN_K origin, unsigned int schema_key, LSD_sdiWriteCbp *write)
 Constructs an Event Filter Statistics handle.
void EFS_post (EFS *efs, int reason, const void *beg, const void *end, const EFA_span *span)
 Formats the datagram and eventually writes the datagram to the output device.
int EFS_sizeof (int max_records)
 Computes the size, in bytes, of the EFS control structure.
int EFS_start (EFS *efs, int reason, int run_id, int startTime, int mode)
 Captures the start run information.

Variables

static const unsigned char OpenReasons [16]
 Maps a closing reason into its complimentary open reason.

Detailed Description

Event Filter Statistics, Generic.

Author:
JJRussell - russell@slac.stanford.edu
   CVS $Id: EFS.c,v 1.5 2007/12/18 01:27:13 russell Exp $

Function Documentation

static void accumulate EFS_stats stats,
unsigned int  stride,
const void *  beg,
const void *  end
[static]
 

Accumulates the event statistics for the results from beg to end.

Parameters:
stats The target statistics block
stride The number of 32-bit words in each results block
beg The first results block
end The last results block (actually one past it)

static __inline void clear EFS efs  )  [static]
 

Clears the statistics block.

Parameters:
efs statistics block to clear.

static __inline void compose_ctx_template EFS_ctxCtb ctb,
unsigned int  sbs,
unsigned int  schema_key,
LSF_CPU_K  cpu,
LSF_ORIGIN_K  origin
[static]
 

Composes the static (one-time fill-in) fields of the context contribution.

Parameters:
ctb The context contribtution to fill-in
sbs The secondary boot script file key
schema_key The handler configuration key (likely FMX key)
cpu The originating cpu
origin The originating data source

static __inline unsigned int * copy unsigned int *  dst,
const unsigned int *  src,
int  nbytes
[static]
 

Copies the specified number of bytes.

Returns:
Pointer to the next destination address to fill
Parameters:
dst The destination address
src The source address
nbytes The number of bytes (must be x4) to copy

unsigned char* EFS_construct EFS efs,
const EFC_DB_SchemaAnalysis *  schema,
int  result_size,
unsigned int  apid_offset,
unsigned int  dgmid_offset,
LSF_CPU_K  cpu,
LSF_ORIGIN_K  origin,
unsigned int  schema_key,
LSD_sdiWriteCbp *  write
 

Constructs an Event Filter Statistics handle.

Returns:
The next available memory location
Parameters:
efs The control handle to be initialized
schema The analysis schema
result_size The size, in 32-bit words, of a result vector This application only uses the first 32-bits assuming them to be a 32-bit Event Filter status mask.
apid_offset The offset to the base value of the APID. This must be a value between 0 - 4. In general it is represented by on of the values LSF_CPU_K_EPU_0,1,2 or LSF_CPU_SIU_0,1
dgmid_offset The offset of the datagram id. The value LSF_ID_K_EFS will be added to this value.
cpu One of the enumeration LSE_CPU_K specifying the CPU that is writing the datagram
origin One of the enumeration LSE_ORIGIN_K specifying the origin of the data
schema_key The, usually FMX, key of the configuration file currently being used to produce the result vectors. This allows the consumer of the EFS datagrams to understand the conditions that the data was taken
write Callback routine and parameter to commit the formatted datagram to the output device

void EFS_post EFS efs,
int  reason,
const void *  beg,
const void *  end,
const EFA_span span
 

Formats the datagram and eventually writes the datagram to the output device.

Parameters:
efs The Event Filter Statistics handle
reason The reason EFS_post is being called. These are enumerated in EFA_FLUSH_REASON but, briefly are the set of the LSF_REASONs augmented to a record update reason and a record process reason.
beg The first result vector to analyze
end The last (actually one past the last) result vector to analyze
span Structure defining the span of events, both in time and event sequence numbers, that are being analyzed.

int EFS_sizeof int  max_records  ) 
 

Computes the size, in bytes, of the EFS control structure.

Returns:
The size, in bytes,
Parameters:
max_records The maximum number of records in a datagram

int EFS_start EFS efs,
int  reason,
int  run_id,
int  startTime,
int  mode
 

Captures the start run information.

Returns:
0 is successful, non-zero otherwise
Parameters:
efs The Event Filter Statistics handle
reason The LSF_REASON_OPEN to indicate why the stream is being started
run_id Suggested use is to identify the block of events between when EDS_fwHandlerStart is called and EDS_fwHandlerFlush is called with a stop reason
startTime The run start time rounded to the nearest second
mode This must be the running mode.

static unsigned int format unsigned int *  dat,
const unsigned int *  buf,
int  n,
unsigned int  max
[static]
 

Encodes the input buffer using a significant bit count followed by the significant bits.

Returns:
The next 32-bit word to fill in
Parameters:
dat The output data buffer
buf The input data buffer
n The number of values to encode
max The maximum value
The format is

       number of bits in the count of number of significant digits (5)
       number of significant digits | significant bits (first + nsig)
       number of significant digits | significant bits
       number of significant digits | significant bits
       .
       .

static LSF_record * format_begin_record LSF_record *  rec,
const EFA_span span,
const EFS_stats stats
[static]
 

Formats a normal record with 2 headers.

Returns:
Pointer to the next record to fill
Parameters:
rec The record to format
span The beginning and ending event sample specification
stats The statistics

static LSF_record * format_diff_record LSF_record *  rec,
const EfsPrvHdr prv_hdr,
const EFA_span span,
const EFS_stats cur,
const EFS_stats prv
[static]
 

Formats a standard statistics record.

Returns:
Pointer to the next record to fill
Parameters:
rec The record to format.
prv_hdr Information about the last event header.
span The beginning and ending event sample specification.
cur The current set of statistics.
prv The previous set of statistics. This is used to form differences with the current set. It is these differences that are encoded

static unsigned int * format_diff_stats unsigned int *  dat,
const EFS_stats cur,
const EFS_stats prv
[static]
 

Format the statisitics buffer as the difference between the current and previous.

Returns:
A pointer to the next data location to fill
Parameters:
dat The data area
cur The current statistics
prv The previous statistics
Each of the two statistics blocks is formatted the same; a bit mask indicating which counters are non-zero followed by an array of 32-bit counters, one for each set bit.

static LSF_record * format_global_record LSF_record *  rec,
const EFA_span span,
const EFS_stats stats
[static]
 

Formats the global statistics record.

Returns:
Pointer to the next record to fill
Parameters:
rec The record to format
span The beginning and ending event sample specification
stats The statistics

static LSF_record * format_record LSF_record *  rec,
const EFA_span span,
const EFS_stats stats
[static]
 

Formats a standard statistics record with one header.

Returns:
Pointer to the next record to fill
Parameters:
rec The record to format
span The beginning and ending event sample specification
stats The statistics

static unsigned int * format_stats unsigned int *  dat,
const EFS_stats stats
[static]
 

Format the statisitics buffer.

Returns:
A pointer to the next data location to fill
Parameters:
dat The data area
stats The statistics block to format
Each of the two statistics blocks is formatted the same; a bit mask indicating which counters are non-zero followed by an array of 32-bit counters, one for each set bit.

static int get_datagram_pool_size int  max_records  )  [static]
 

Calculates the size in bytes of the ring buffer pool size from which the datagrams will be allocated.

Returns:
The size in bytes of the ring buffer pool
Parameters:
max_records The maximum number of records.
The datagram pool size is determined by allocating NPACKETS of the maximal datagram size. The maximal datagram size assumes no compression, which is usually in the range of 2-4.

A reasonable number of records would be less than 50. This will give a datagram size of around 17Kbytes.

static int get_datagram_size int  max_records  )  [static]
 

Computes, in bytes, the maximal size of a datagram of max_records.

Returns:
The size of a maximal datagram
Parameters:
max_records The maximum number of records in a datagram
This calculation is based on computing the maximal size of a datagram, ignoring compression. The calculation is dominated by the size of max_records number of records. The other datagram overhead is minimal. Each record can take up to 2 full headers (40 bytes each, total of 80) + 64 4 byte counters (256 bytes) for a total of 336 bytes. For example a datagram of 50 records would take approximately 17Kbytes.

static unsigned int sbsKeyGet void   )  [static]
 

Retrieves the secondary boot script key.

Returns:
The secondary boot script key, or 0 if none
On host machines, this always returns 0. On embedded system machines this may return 0 if the secondary boot script is RAM based.


Variable Documentation

unsigned char OpenReasons[16] [static]
 

Initial value:

{
  LSF_REASON_OPEN_K_START,      
  LSF_REASON_OPEN_K_START_OP,   
  LSF_REASON_OPEN_K_AUTO_TIME,  
  LSF_REASON_OPEN_K_AUTO_COUNT, 


                                
  LSF_REASON_OPEN_K_START,      
  LSF_REASON_OPEN_K_START_OP,   
  LSF_REASON_OPEN_K_START_AUTO, 
  LSF_REASON_OPEN_K_START,      

                                
  LSF_REASON_OPEN_K_RESUME,     
  LSF_REASON_OPEN_K_RESUME_OP,  
  LSF_REASON_OPEN_K_RESUME_AUTO,

                                
  LSF_REASON_OPEN_K_AUTO,       
  LSF_REASON_OPEN_K_AUTO_MODE,  
  LSF_REASON_CLOSE_K_AUTO_TIME, 
  LSF_REASON_CLOSE_K_AUTO_COUNT,
  LSF_REASON_CLOSE_K_AUTO_FULL  
}
Maps a closing reason into its complimentary open reason.

When a datagram is closed, it is highly likely that a new one will be opened. This new datagram needs a reason for being opened. In many cases this reopening is automatic, so the opening reason must be internally generated. This array fills that need, mapping an closing reason into its complimentary open reason.
Even though this maps all close reasons, some the close reasons are not automatically and likely will not be used. For completeness, a reasonable value is filled in. These entries are marked in the comments with an XX


Generated on Fri Sep 5 01:21:19 2008 by  doxygen 1.4.4