Velocity Userspace
Functions
Miscellaneous Commands

Various functions that fit don't fit into other categories. More...

Functions

int switchtec_echo (struct switchtec_dev *dev, uint32_t input, uint32_t *output)
 Perform an MRPC echo command. More...
 
int switchtec_hard_reset (struct switchtec_dev *dev)
 Perform an MRPC hard reset command. More...
 
static void free_log_defs (struct log_defs *defs)
 Free log definition data. More...
 
static int realloc_log_defs (struct log_defs *defs, int num_modules)
 Allocate / reallocate log definition data. More...
 
static bool parse_int (char *str, int *val)
 Parse an integer from a string. More...
 
static int read_app_log_defs (FILE *log_def_file, struct log_defs *defs)
 Read an app log definition file and store the definitions. More...
 
static int read_mailbox_log_defs (FILE *log_def_file, struct log_defs *defs)
 Read a mailbox log definition file and store the definitions. More...
 
static int write_parsed_log (struct log_a_data log_data[], size_t count, int init_entry_idx, struct log_defs *defs, enum switchtec_log_parse_type log_type, FILE *log_file, int ts_factor)
 Parse an app log or mailbox log and write the results to a file. More...
 
int switchtec_log_to_file (struct switchtec_dev *dev, enum switchtec_log_type type, int fd, FILE *log_def_file, struct switchtec_log_file_info *info)
 Dump the Switchtec log data to a file. More...
 
int switchtec_parse_log (FILE *bin_log_file, FILE *log_def_file, FILE *parsed_log_file, enum switchtec_log_parse_type log_type, enum switchtec_gen gen, struct switchtec_log_file_info *info)
 Parse a binary app log or mailbox log to a text file. More...
 
int switchtec_log_def_to_file (struct switchtec_dev *dev, enum switchtec_log_def_type type, FILE *file)
 Dump the Switchtec log definition data to a file. More...
 
int switchtec_get_device_info (struct switchtec_dev *dev, enum switchtec_boot_phase *phase, enum switchtec_gen *gen, enum switchtec_rev *rev, struct ping_dev_info *ping_info)
 Get device generation, revision, and boot phase info. More...
 
float switchtec_die_temp (struct switchtec_dev *dev)
 Get the die temperature of the switchtec device. More...
 
int switchtec_calc_lane_id (struct switchtec_dev *dev, int phys_port_id, int lane_id, struct switchtec_status *port)
 Calculate the global lane ID for a lane within a physical port. More...
 
int switchtec_calc_port_lane (struct switchtec_dev *dev, int lane_id, int *phys_port_id, int *port_lane_id, struct switchtec_status *port)
 Calculate the port and lane within the port from a global lane ID. More...
 
int switchtec_calc_lane_mask (struct switchtec_dev *dev, int phys_port_id, int lane_id, int num_lanes, int *lane_mask, struct switchtec_status *port)
 Calculate the lane mask for lanes within a physical port. More...
 
bool switchtec_stack_bif_port_valid (struct switchtec_dev *dev, int stack_id, int port_id)
 Return true if a port within a stack is valid. More...
 
int switchtec_stack_bif_width (struct switchtec_dev *dev, int stack_id, int port_bif)
 Return the number of stack ports used for a given bifurcation. More...
 
int switchtec_get_stack_bif (struct switchtec_dev *dev, int stack_id, int port_bif[SWITCHTEC_PORTS_PER_STACK])
 Get the bifurcation of ports in a stack. More...
 
int switchtec_set_stack_bif (struct switchtec_dev *dev, int stack_id, int port_bif[SWITCHTEC_PORTS_PER_STACK])
 Set the bifurcation of ports in a stack. More...
 
int switchtec_pff_to_port (struct switchtec_dev *dev, int pff, int *partition, int *port)
 Convert a port function index to a partition and port number. More...
 
int switchtec_port_to_pff (struct switchtec_dev *dev, int partition, int port, int *pff)
 Convert a partition and port number to a port function index. More...
 

Detailed Description

Various functions that fit don't fit into other categories.

Function Documentation

◆ free_log_defs()

static void free_log_defs ( struct log_defs defs)
static

Free log definition data.

Parameters
[in]defs- log definition data to free

Definition at line 846 of file switchtec.c.

◆ parse_int()

static bool parse_int ( char *  str,
int *  val 
)
static

Parse an integer from a string.

Parameters
[in]str- string to parse
[out]val- integer
Returns
true on success, false on failure

Definition at line 898 of file switchtec.c.

◆ read_app_log_defs()

static int read_app_log_defs ( FILE *  log_def_file,
struct log_defs defs 
)
static

Read an app log definition file and store the definitions.

Parameters
[in]log_def_file- log definition file
[out]defs- log definitions
Returns
0 on success, negative value on failure

Definition at line 917 of file switchtec.c.

◆ read_mailbox_log_defs()

static int read_mailbox_log_defs ( FILE *  log_def_file,
struct log_defs defs 
)
static

Read a mailbox log definition file and store the definitions.

Parameters
[in]log_def_file- log definition file
[out]defs- log definitions
Returns
0 on success, negative value on failure

Definition at line 1026 of file switchtec.c.

◆ realloc_log_defs()

static int realloc_log_defs ( struct log_defs defs,
int  num_modules 
)
static

Allocate / reallocate log definition data.

Parameters
[in]defs- log definition data
[in]num_modules- number of modules to allocate for
Returns
0 on success, negative value on failure

Definition at line 871 of file switchtec.c.

◆ switchtec_calc_lane_id()

int switchtec_calc_lane_id ( struct switchtec_dev *  dev,
int  phys_port_id,
int  lane_id,
struct switchtec_status port 
)

Calculate the global lane ID for a lane within a physical port.

Parameters
[in]devSwitchtec device handle
[in]phys_port_idPhysical port id
[in]lane_idLane number within the port
[out]statusOptionally return the status of the port
Returns
The lane id or -1 on error (with errno set appropriately)

Definition at line 1997 of file switchtec.c.

◆ switchtec_calc_lane_mask()

int switchtec_calc_lane_mask ( struct switchtec_dev *  dev,
int  phys_port_id,
int  lane_id,
int  num_lanes,
int *  lane_mask,
struct switchtec_status port 
)

Calculate the lane mask for lanes within a physical port.

Parameters
[in]devSwitchtec device handle
[in]phys_port_idPhysical port id
[in]lane_idLane number within the port
[in]num_lanesNumber of consecutive lanes to set
[out]lane_maskPointer to array of 4 integers to set the bits of the lanes to
[out]statusOptionally, return the status of the port
Returns
The 0 or -1 on error (with errno set appropriately)

Definition at line 2101 of file switchtec.c.

◆ switchtec_calc_port_lane()

int switchtec_calc_port_lane ( struct switchtec_dev *  dev,
int  lane_id,
int *  phys_port_id,
int *  port_lane_id,
struct switchtec_status port 
)

Calculate the port and lane within the port from a global lane ID.

Parameters
[in]devSwitchtec device handle
[in]lane_idGlobal Lane Number
[out]phys_port_idPhysical port id
[out]port_laneLane number within the port
[out]statusOptionally return the status of the port
Returns
The 0 on success or -1 on error (with errno set appropriately)

Definition at line 2037 of file switchtec.c.

◆ switchtec_die_temp()

float switchtec_die_temp ( struct switchtec_dev *  dev)

Get the die temperature of the switchtec device.

Parameters
[in]devSwitchtec device handle
Returns
The die temperature (in degrees celsius) or a negative value on failure

Definition at line 1887 of file switchtec.c.

◆ switchtec_echo()

int switchtec_echo ( struct switchtec_dev *  dev,
uint32_t  input,
uint32_t *  output 
)

Perform an MRPC echo command.

Parameters
[in]devSwitchtec device handle
[in]inputThe input data for the echo command
[out]outputThe result of the echo command
Returns
0 on success, error code on failure

The echo command takes 4 bytes and returns the bitwise-not of those bytes.

Definition at line 818 of file switchtec.c.

◆ switchtec_get_device_info()

int switchtec_get_device_info ( struct switchtec_dev *  dev,
enum switchtec_boot_phase phase,
enum switchtec_gen gen,
enum switchtec_rev rev,
struct ping_dev_info ping_info 
)

Get device generation, revision, and boot phase info.

Parameters
[in]devSwitchtec device handle
[out]phaseThe current boot phase
[out]genDevice generation
[out]revDevice revision
Returns
0 on success, error code on failure

Definition at line 1802 of file switchtec.c.

◆ switchtec_get_stack_bif()

int switchtec_get_stack_bif ( struct switchtec_dev *  dev,
int  stack_id,
int  port_bif[SWITCHTEC_PORTS_PER_STACK] 
)

Get the bifurcation of ports in a stack.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack ID to get the bifurcation of
[out]port_bifPort bifurcation returned
Returns
0 on success, or a negative value on failure

Definition at line 2189 of file switchtec.c.

◆ switchtec_hard_reset()

int switchtec_hard_reset ( struct switchtec_dev *  dev)

Perform an MRPC hard reset command.

Parameters
[in]devSwitchtec device handle
Returns
0 on success, error code on failure

Note: if your system does not support hotplug this may leave the Switchtec device in an unusable state. A reboot would be required to fix this.

Definition at line 834 of file switchtec.c.

◆ switchtec_log_def_to_file()

int switchtec_log_def_to_file ( struct switchtec_dev *  dev,
enum switchtec_log_def_type  type,
FILE *  file 
)

Dump the Switchtec log definition data to a file.

Parameters
[in]dev- Switchtec device handle
[in]type- Type of log definition data to dump
[in]file- File descriptor to dump the data to
Returns
0 on success, error code on failure

Definition at line 1698 of file switchtec.c.

◆ switchtec_log_to_file()

int switchtec_log_to_file ( struct switchtec_dev *  dev,
enum switchtec_log_type  type,
int  fd,
FILE *  log_def_file,
struct switchtec_log_file_info info 
)

Dump the Switchtec log data to a file.

Parameters
[in]dev- Switchtec device handle
[in]type- Type of log data to dump
[in]fd- File descriptor to dump the data to
[in]log_def_file- Log definition file
[out]info- Log file information
Returns
0 on success, error code on failure

Definition at line 1505 of file switchtec.c.

◆ switchtec_parse_log()

int switchtec_parse_log ( FILE *  bin_log_file,
FILE *  log_def_file,
FILE *  parsed_log_file,
enum switchtec_log_parse_type  log_type,
enum switchtec_gen  gen,
struct switchtec_log_file_info info 
)

Parse a binary app log or mailbox log to a text file.

Parameters
[in]bin_log_file- Binary log input file
[in]log_def_file- Log definition file
[in]parsed_log_file- Parsed output file
[in]log_type- log type
[in]gen- device generation
[out]info- log file information
Returns
0 on success, error code on failure

Definition at line 1586 of file switchtec.c.

◆ switchtec_pff_to_port()

int switchtec_pff_to_port ( struct switchtec_dev *  dev,
int  pff,
int *  partition,
int *  port 
)

Convert a port function index to a partition and port number.

Parameters
[in]devSwitchtec device handle
[in]pffPort function number
[out]partitionPartition number
[out]portPort number
Returns
0 on success, negative on failure

Definition at line 213 of file platform.c.

◆ switchtec_port_to_pff()

int switchtec_port_to_pff ( struct switchtec_dev *  dev,
int  partition,
int  port,
int *  pff 
)

Convert a partition and port number to a port function index.

Parameters
[in]devSwitchtec device handle
[in]partitionPartition number
[in]portPort number
[out]pffPort function number
Returns
0 on success, negative on failure

Definition at line 228 of file platform.c.

◆ switchtec_set_stack_bif()

int switchtec_set_stack_bif ( struct switchtec_dev *  dev,
int  stack_id,
int  port_bif[SWITCHTEC_PORTS_PER_STACK] 
)

Set the bifurcation of ports in a stack.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack ID to get the bifurcation of
[in]port_bifPort bifurcation returned
Returns
0 on success, or a negative value on failure

Definition at line 2233 of file switchtec.c.

◆ switchtec_stack_bif_port_valid()

bool switchtec_stack_bif_port_valid ( struct switchtec_dev *  dev,
int  stack_id,
int  port_id 
)

Return true if a port within a stack is valid.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack ID
[out]port_idPort ID within the stack
Returns
true if the port is valid, false otherwise

Definition at line 2148 of file switchtec.c.

◆ switchtec_stack_bif_width()

int switchtec_stack_bif_width ( struct switchtec_dev *  dev,
int  stack_id,
int  port_bif 
)

Return the number of stack ports used for a given bifurcation.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack ID
[in]port_bifPort bifurcation
Returns
width on success, or a negative value on failure

Definition at line 2164 of file switchtec.c.

◆ write_parsed_log()

static int write_parsed_log ( struct log_a_data  log_data[],
size_t  count,
int  init_entry_idx,
struct log_defs defs,
enum switchtec_log_parse_type  log_type,
FILE *  log_file,
int  ts_factor 
)
static

Parse an app log or mailbox log and write the results to a file.

Parameters
[in]log_data- logging data
[in]count- number of entries
[in]init_entry_idx- index of the initial entry
[in]defs- log definitions
[in]log_type- log type
[in]log_file- log output file
[in]ts_factor- timestamp conversion factor
Returns
0 on success, negative value on failure

Definition at line 1096 of file switchtec.c.