Switchtec Userspace  PROJECT_NUMBER = PROJECT_NUMBER=PROJECT_NUMBER = 2.2
Functions
Event Management

List and wait for switch events. More...

Functions

int switchtec_event_summary_set (struct switchtec_event_summary *sum, enum switchtec_event_id e, int index)
 Set a bit corresponding to an event in a summary structure. More...
 
int switchtec_event_summary_test (struct switchtec_event_summary *sum, enum switchtec_event_id e, int index)
 Test if a bit corresponding to an event is set in a summary structure. More...
 
int switchtec_event_summary_iter (struct switchtec_event_summary *sum, enum switchtec_event_id *e, int *idx)
 Iterate through all set bits in an event summary structure. More...
 
int switchtec_event_check (struct switchtec_dev *dev, struct switchtec_event_summary *chk, struct switchtec_event_summary *res)
 Check if one or more events have occurred. More...
 
enum switchtec_event_type switchtec_event_info (enum switchtec_event_id e, const char **name, const char **desc)
 Get the name and description strings as well as the type (global, partition or pff) for a specific event ID. More...
 
int switchtec_event_wait_for (struct switchtec_dev *dev, enum switchtec_event_id e, int index, struct switchtec_event_summary *res, int timeout_ms)
 Block until a specific event occurs. More...
 
int switchtec_event_summary (struct switchtec_dev *dev, struct switchtec_event_summary *sum)
 Retrieve a summary of all the events that have occurred in the switch. More...
 
int switchtec_event_ctl (struct switchtec_dev *dev, enum switchtec_event_id e, int index, int flags, uint32_t data[5])
 Enable, disable and clear events or retrieve event data. More...
 
int switchtec_event_wait (struct switchtec_dev *dev, int timeout_ms)
 Wait for any event to occur (typically just an interrupt) More...
 

Detailed Description

List and wait for switch events.

switchtec_event_info() provides an interface to list all possible switch events. switchtec_event_summary() gives a bitmask of events that have occured since they were last cleared. switchtec_event_ctl() can be used to clear and event or manage what happens when an event occurs. switchtec_event_wait_for() may be used to block until a specific event occurs.

Function Documentation

int switchtec_event_check ( struct switchtec_dev *  dev,
struct switchtec_event_summary chk,
struct switchtec_event_summary res 
)

Check if one or more events have occurred.

Parameters
[in]devSwitchtec device handle
[in]chkSummary structure with events to check
[out]resReturned current events summary, (may be NULL)
Returns
1 if one of the events in chk occurred, 0 otherwise or a negative value if an error occurred.

Definition at line 297 of file events.c.

int switchtec_event_ctl ( struct switchtec_dev *  dev,
enum switchtec_event_id  e,
int  index,
int  flags,
uint32_t  data[5] 
)

Enable, disable and clear events or retrieve event data.

Parameters
[in]devSwitchtec device handle
[in]eEvent to operate on
[in]indexEvent index (partition or port, depending on event)
[in]flagsAny of the SWITCHTEC_EVT_FLAGs
[out]dataReturned event data reported by the switch
Returns
0 on success, negative on failure

Definition at line 281 of file platform.c.

enum switchtec_event_type switchtec_event_info ( enum switchtec_event_id  e,
const char **  name,
const char **  desc 
)

Get the name and description strings as well as the type (global, partition or pff) for a specific event ID.

Parameters
[in]eEvent ID to get the strings for
[out]nameName string of the event
[out]descDescription string of the event
Returns
The event type

Definition at line 343 of file events.c.

int switchtec_event_summary ( struct switchtec_dev *  dev,
struct switchtec_event_summary sum 
)

Retrieve a summary of all the events that have occurred in the switch.

Parameters
[in]devSwitchtec device handle
[out]sumStructure to place the result in
Returns
0 on success, negative on failure

Definition at line 265 of file platform.c.

int switchtec_event_summary_iter ( struct switchtec_event_summary sum,
enum switchtec_event_id e,
int *  idx 
)

Iterate through all set bits in an event summary structure.

Parameters
[in]sumSummary structure to set the bit in
[out]eEvent ID which was set
[out]idxEvent index (partition or port, depending on event)
Returns
1 if a bit is set, 0 otherwise

This function is meant to be called in a loop. It finds the lowest bit set and returns the corresponding event id and index. It then clears that bit in the structure.

Definition at line 248 of file events.c.

int switchtec_event_summary_set ( struct switchtec_event_summary sum,
enum switchtec_event_id  e,
int  index 
)

Set a bit corresponding to an event in a summary structure.

Parameters
[in]sumSummary structure to set the bit in
[in]eEvent ID to set
[in]indexEvent index (partition or port, depending on event)
Returns
0 on success, or -EINVAL if the index was invalid

Definition at line 175 of file events.c.

int switchtec_event_summary_test ( struct switchtec_event_summary sum,
enum switchtec_event_id  e,
int  index 
)

Test if a bit corresponding to an event is set in a summary structure.

Parameters
[in]sumSummary structure to set the bit in
[in]eEvent ID to test
[in]indexEvent index (partition or port, depending on event)
Returns
1 if the bit is set, 0 otherwise

Definition at line 219 of file events.c.

int switchtec_event_wait ( struct switchtec_dev *  dev,
int  timeout_ms 
)

Wait for any event to occur (typically just an interrupt)

Parameters
[in]devSwitchtec device handle
[in]timeout_msTimeout ofter this many milliseconds
Returns
1 if the event occurred, 0 if it timed out, negative in case of an error

Definition at line 297 of file platform.c.

int switchtec_event_wait_for ( struct switchtec_dev *  dev,
enum switchtec_event_id  e,
int  index,
struct switchtec_event_summary res,
int  timeout_ms 
)

Block until a specific event occurs.

Parameters
[in]devSwitchtec device handle
[in]eEvent ID to wait for
[in]indexEvent index (partition or port)
[out]resCurrent event summary set, after waiting
[in]timeout_msTimeout of this many milliseconds
Returns
1 if the event occurred, 0 on a timeout and a negative number an error.

Definition at line 369 of file events.c.