Velocity Userspace
Classes | Functions | Variables
switchtec.c File Reference

Switchtec core library functions for basic device operations. More...

#include "switchtec_priv.h"
#include "switchtec/switchtec.h"
#include "switchtec/mrpc.h"
#include "switchtec/errors.h"
#include "switchtec/log.h"
#include "switchtec/endian.h"
#include "switchtec/utils.h"
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
Include dependency graph for switchtec.c:

Go to the source code of this file.

Classes

struct  module_log_defs
 Module-specific log definitions. More...
 
struct  log_defs
 Log definitions for all modules. More...
 
struct  switchtec_device_id
 Switchtec device id to generation/variant mapping. More...
 

Functions

static int set_local_pax_id (struct switchtec_dev *dev)
 
void switchtec_list_free (struct switchtec_device_info *devlist)
 Free a list of device info structures allocated by switchtec_list() More...
 
struct switchtec_dev * switchtec_open (const char *device)
 Open a Switchtec device by string. More...
 
_PURE int switchtec_device_id (struct switchtec_dev *dev)
 Get the device id of the device. More...
 
_PURE enum switchtec_gen switchtec_gen (struct switchtec_dev *dev)
 Get the generation of the device. More...
 
_PURE enum switchtec_variant switchtec_variant (struct switchtec_dev *dev)
 Get the variant type of the device. More...
 
_PURE enum switchtec_boot_phase switchtec_boot_phase (struct switchtec_dev *dev)
 Get boot phase of the device. More...
 
const _PURE char * switchtec_name (struct switchtec_dev *dev)
 Get the string that was used to open the deviec. More...
 
_PURE int switchtec_partition (struct switchtec_dev *dev)
 Get the partiton number of the device that was opened. More...
 
int switchtec_status (struct switchtec_dev *dev, struct switchtec_status **status)
 Get the status of all the ports on a switchtec device. More...
 
void switchtec_status_free (struct switchtec_status *status, int ports)
 Free a list of status structures allocated by switchtec_status() More...
 
const char * switchtec_strerror (void)
 Return a message coresponding to the last error. More...
 
void switchtec_perror (const char *str)
 Print an error string to stdout. More...
 
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...
 

Variables

static const struct switchtec_device_id switchtec_device_id_tbl []
 Supported Switchtec device id table.
 
int mrpc_error_cmd
 The MRPC command ID when errno is set. More...
 

Detailed Description

Switchtec core library functions for basic device operations.

Definition in file switchtec.c.