Switchtec Userspace  PROJECT_NUMBER = PROJECT_NUMBER=PROJECT_NUMBER = 2.2
Functions
Performance Monitor

Setup and query performance monitors in the switch. More...

Functions

int switchtec_evcntr_type_count (void)
 Get the number of event counter types. More...
 
const char * switchtec_evcntr_type_str (int *type_mask)
 Get a string for the event indicated by lowest bit set in the type_mask. More...
 
int switchtec_evcntr_setup (struct switchtec_dev *dev, unsigned stack_id, unsigned cntr_id, struct switchtec_evcntr_setup *setup)
 Setup an event counter performance monitor. More...
 
int switchtec_evcntr_get_setup (struct switchtec_dev *dev, unsigned stack_id, unsigned cntr_id, unsigned nr_cntrs, struct switchtec_evcntr_setup *res)
 Retrieve the setup information for one or more event counters. More...
 
int switchtec_evcntr_get (struct switchtec_dev *dev, unsigned stack_id, unsigned cntr_id, unsigned nr_cntrs, unsigned *res, int clear)
 Retrieve the current counts for one or more event counters. More...
 
int switchtec_evcntr_get_both (struct switchtec_dev *dev, unsigned stack_id, unsigned cntr_id, unsigned nr_cntrs, struct switchtec_evcntr_setup *setup, unsigned *counts, int clear)
 Retrieve the current counts and setup information for one or more event counters. More...
 
int switchtec_evcntr_wait (struct switchtec_dev *dev, int timeout_ms)
 Block until any event counter has reached its threshold. More...
 
void switchtec_bwcntr_sub (struct switchtec_bwcntr_res *new_cntr, struct switchtec_bwcntr_res *old_cntr)
 Subtract all the values between two bwcntr result structures. More...
 
int switchtec_bwcntr_set_many (struct switchtec_dev *dev, int nr_ports, int *phys_port_ids, enum switchtec_bw_type bw_type)
 Set bandwidth type for a number of ports. More...
 
int switchtec_bwcntr_set_all (struct switchtec_dev *dev, enum switchtec_bw_type bw_type)
 Set bandwidth type for all the ports in the system. More...
 
int switchtec_bwcntr_many (struct switchtec_dev *dev, int nr_ports, int *phys_port_ids, int clear, struct switchtec_bwcntr_res *res)
 Retrieve the bandwidth counter results for a number of ports. More...
 
int switchtec_bwcntr_all (struct switchtec_dev *dev, int clear, struct switchtec_port_id **ports, struct switchtec_bwcntr_res **res)
 Retrieve the bandwidth counter results for all the ports in the system. More...
 
uint64_t switchtec_bwcntr_tot (struct switchtec_bwcntr_dir *d)
 Get the total. More...
 
int switchtec_lat_setup_many (struct switchtec_dev *dev, int nr_ports, int *egress_port_ids, int *ingress_port_ids)
 Setup a number of latency counters. More...
 
int switchtec_lat_setup (struct switchtec_dev *dev, int egress_port_id, int ingress_port_id, int clear)
 Setup a latency counter. More...
 
int switchtec_lat_get_many (struct switchtec_dev *dev, int nr_ports, int clear, int *egress_port_ids, int *cur_ns, int *max_ns)
 Get a number of latency counter results. More...
 
int switchtec_lat_get (struct switchtec_dev *dev, int clear, int egress_port_ids, int *cur_ns, int *max_ns)
 Get a single latency counter result. More...
 

Detailed Description

Setup and query performance monitors in the switch.

switchtec_evcntr_setup() and switchtec_evcntr_get() may be used to setup and query switch event counters which can count errors or TLP packets through different ports.

switchtec_bwcntr_many() and switchtec_bwcntr_all() may be used to retrieve byte counts through one or more ports in the system. When divided by time, these values provide the bandwidth through the switch ports.

switchtec_lat_setup() and switchtec_lat_get() may be used to setup and query latency counter measurements to find out how long packets take to traverse the switch.

Function Documentation

int switchtec_bwcntr_all ( struct switchtec_dev *  dev,
int  clear,
struct switchtec_port_id **  ports,
struct switchtec_bwcntr_res **  res 
)

Retrieve the bandwidth counter results for all the ports in the system.

Parameters
[in]devSwitchtec device handle
[in]clearIf non-zero, clear all the retrieved counters
[out]portsAllocated array of ports retrieved
[out]resAllocated array of bandwidth counter results
Returns
0 on success, error code on failure

ports and res should be freed with free() once they are finished with.

Definition at line 473 of file pmon.c.

int switchtec_bwcntr_many ( struct switchtec_dev *  dev,
int  nr_ports,
int *  phys_port_ids,
int  clear,
struct switchtec_bwcntr_res res 
)

Retrieve the bandwidth counter results for a number of ports.

Parameters
[in]devSwitchtec device handle
[in]nr_portsNumber of ports to retrieve
[in]phys_port_idsThe physical ids for each port to retrieve
[in]clearIf non-zero, clear all the retrieved counters o zero
[out]resList of bandwidth counter results structures (at least nr_ports elements)
Returns
number of ports retrieved on success, negative error code on failure

Definition at line 419 of file pmon.c.

int switchtec_bwcntr_set_all ( struct switchtec_dev *  dev,
enum switchtec_bw_type  bw_type 
)

Set bandwidth type for all the ports in the system.

Parameters
[in]devSwitchtec device handle
[in]bw_typeType of bandwidth to set
Returns
0 on success, error code on failure

Definition at line 387 of file pmon.c.

int switchtec_bwcntr_set_many ( struct switchtec_dev *  dev,
int  nr_ports,
int *  phys_port_ids,
enum switchtec_bw_type  bw_type 
)

Set bandwidth type for a number of ports.

Parameters
[in]devSwitchtec device handle
[in]nr_portsNumber of ports to set
[in]phys_port_idsThe physical ids for each port to set
[in]bw_typeType of bandwidth to set
Returns
0 on success, error code on failure

Definition at line 359 of file pmon.c.

void switchtec_bwcntr_sub ( struct switchtec_bwcntr_res new_cntr,
struct switchtec_bwcntr_res old_cntr 
)

Subtract all the values between two bwcntr result structures.

Parameters
[in,out]new_cntr
[in]old_cntrnew_cntr will have it's original values minus all the values in old_cntr

Definition at line 339 of file pmon.c.

uint64_t switchtec_bwcntr_tot ( struct switchtec_bwcntr_dir *  d)

Get the total.

Parameters
[in]dBandwidth counter direction result
Returns
The total number for posted, non-posted and completions

Definition at line 513 of file pmon.c.

int switchtec_evcntr_get ( struct switchtec_dev *  dev,
unsigned  stack_id,
unsigned  cntr_id,
unsigned  nr_cntrs,
unsigned *  res,
int  clear 
)

Retrieve the current counts for one or more event counters.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack to setup this counter in
[in]cntr_idCounter ID to setup
[in]nr_cntrsNumber of counters to retrieve
[out]resList of unsigned values to return the current counts in (at least nr_cntrs elements)
[in]clearIf non-zero, clear all the retrieved counters to zero
Returns
0 on success, error code on failure

Retrieves nr_cntrs counter values sequentially starting at cntr_id

Definition at line 257 of file pmon.c.

int switchtec_evcntr_get_both ( struct switchtec_dev *  dev,
unsigned  stack_id,
unsigned  cntr_id,
unsigned  nr_cntrs,
struct switchtec_evcntr_setup setup,
unsigned *  counts,
int  clear 
)

Retrieve the current counts and setup information for one or more event counters.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack to setup this counter in
[in]cntr_idCounter ID to setup
[in]nr_cntrsNumber of counters to retrieve
[out]setupList of event counter setup structures (at least nr_cntrs elements)
[out]countsList of unsigned values to return the current counts in (at least nr_cntrs elements)
[in]clearIf non-zero, clear all the retrieved counters to zero
Returns
0 on success, error code on failure

Retrieves nr_cntrs counter values and setup structures sequentially starting at cntr_id. This is equivalent to calling switchtec_evcntr_get() and switchtec_evcntr_get_setup().

Definition at line 301 of file pmon.c.

int switchtec_evcntr_get_setup ( struct switchtec_dev *  dev,
unsigned  stack_id,
unsigned  cntr_id,
unsigned  nr_cntrs,
struct switchtec_evcntr_setup res 
)

Retrieve the setup information for one or more event counters.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack to setup this counter in
[in]cntr_idFirst counter ID to retrieve
[in]nr_cntrsNumber of counters to retrieve
[out]resList of event counter setup structures (at least nr_cntrs elements)
Returns
0 on success, error code on failure

Retrieves nr_cntrs setup structures sequentially starting at cntr_id

Definition at line 214 of file pmon.c.

int switchtec_evcntr_setup ( struct switchtec_dev *  dev,
unsigned  stack_id,
unsigned  cntr_id,
struct switchtec_evcntr_setup setup 
)

Setup an event counter performance monitor.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack to setup this counter in
[in]cntr_idCounter ID to setup
[in]setupEvent counter setup structure
Returns
0 on success, error code on failure

Definition at line 139 of file pmon.c.

int switchtec_evcntr_type_count ( void  )

Get the number of event counter types.

Returns
The number of types

Definition at line 95 of file pmon.c.

const char* switchtec_evcntr_type_str ( int *  type_mask)

Get a string for the event indicated by lowest bit set in the type_mask.

Parameters
[in,out]type_maskBitmask of types
Returns
Name string

Clears the lowest bit in type_mask and returns the string corresponding to that type. Thus, this function can be used in a loop to print a list of strings representing a bit mask of types.

Definition at line 116 of file pmon.c.

int switchtec_evcntr_wait ( struct switchtec_dev *  dev,
int  timeout_ms 
)

Block until any event counter has reached its threshold.

Parameters
[in]devSwitchtec device handle
[in]timeout_msStop waiting after the specified number of milliseconds
Returns
1 if the event occurred, 0 if a timeout occurred, a negative value if an error occurred

Definition at line 325 of file pmon.c.

int switchtec_lat_get ( struct switchtec_dev *  dev,
int  clear,
int  egress_port_ids,
int *  cur_ns,
int *  max_ns 
)

Get a single latency counter result.

Parameters
[in]devSwitchtec device handle
[in]clearIf non-zero, clear the latency counter
[in]egress_port_idsThe egress port of the latency counter to retrieve
[out]cur_nsThe current latency value
[out]max_nsThe maximum latency value
Returns
1 on success, error code on failure

Results are reported in nanoseconds.

Definition at line 633 of file pmon.c.

int switchtec_lat_get_many ( struct switchtec_dev *  dev,
int  nr_ports,
int  clear,
int *  egress_port_ids,
int *  cur_ns,
int *  max_ns 
)

Get a number of latency counter results.

Parameters
[in]devSwitchtec device handle
[in]nr_portsNumber of latency counters to retrieve
[in]clearIf non-zero, clear the latency counters
[in]egress_port_idsA list of port ids for the counters to return
[out]cur_nsA list of current latency values
[out]max_nsA list of maximum latency values
Returns
nr_ports on success, error code on failure

Results are reported in nanoseconds.

Definition at line 585 of file pmon.c.

int switchtec_lat_setup ( struct switchtec_dev *  dev,
int  egress_port_id,
int  ingress_port_id,
int  clear 
)

Setup a latency counter.

Parameters
[in]devSwitchtec device handle
[in]egress_port_idThe port id for the egress of the TLP
[in]ingress_port_idThe port id for the ingress of the TLP (may be SWITCHTEC_LAT_ALL_INGRESS for all ports)
[in]clearIf non-zero, clear the latency counter
Returns
1 on success, error code on failure

Definition at line 557 of file pmon.c.

int switchtec_lat_setup_many ( struct switchtec_dev *  dev,
int  nr_ports,
int *  egress_port_ids,
int *  ingress_port_ids 
)

Setup a number of latency counters.

Parameters
[in]devSwitchtec device handle
[in]nr_portsNumber of latency counters to setup
[in]egress_port_idsA list of port ids for the egress of the TLP
[in]ingress_port_idsA list of port ids for the ingress of the TLP (may be SWITCHTEC_LAT_ALL_INGRESS for all ports)
Returns
0 on success, error code on failure

Definition at line 527 of file pmon.c.