Velocity Userspace
Classes | Typedefs | Enumerations | Functions | Variables
switchtec.h File Reference

Main Switchtec header. More...

#include "mrpc.h"
#include "bind.h"
#include "portable.h"
#include "registers.h"
#include "utils.h"
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
Include dependency graph for switchtec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  switchtec_device_info
 Represents a Switchtec device in the switchtec_list() function. More...
 
struct  switchtec_port_id
 Port identification. More...
 
struct  switchtec_status
 Port status structure. More...
 
struct  ping_dev_info
 
struct  switchtec_log_file_info
 Information about log file and log definition file. More...
 
struct  switchtec_fw_image_info
 Information about a firmware image or partition. More...
 
struct  switchtec_fw_part_summary
 
struct  switchtec_fw_part_summary::switchtec_fw_part_type
 
struct  switchtec_event_summary
 Event summary bitmaps. More...
 
struct  switchtec_evcntr_type_list
 Null-terminated list of all event counter types with a name and help text. More...
 
struct  switchtec_evcntr_setup
 Structure used to setup an event counter. More...
 
struct  switchtec_bwcntr_res
 Bandwidth counter result struct. More...
 
struct  switchtec_bwcntr_res::switchtec_bwcntr_dir
 
struct  switchtec_diag_cross_hair
 
struct  switchtec_rcvr_obj
 
struct  switchtec_port_eq_coeff
 
struct  switchtec_port_eq_table
 
struct  switchtec_port_eq_tx_fslf
 
struct  switchtec_rcvr_ext
 
struct  switchtec_mrpc
 
struct  switchtec_diag_ltssm_log
 

Typedefs

typedef __gas struct switchtec_gasgasptr_t
 Shortform for a pointer to the GAS register space.
 

Enumerations

enum  switchtec_gen
 The PCIe generations.
 
enum  stmfd_rev
 Device hardware revision for Stamford Platform.
 
enum  switchtec_rev
 Device hardware revision.
 
enum  switchtec_boot_phase
 Device boot phase.
 
enum  stmfd_rcvry_reason
 Device boot recovery reason.
 
enum  switchtec_variant
 The variant types of Switchtec device.
 
enum  switchtec_bw_type
 The types of bandwidth.
 
enum  switchtec_log_type
 Describe the type of logs too dump. More...
 
enum  switchtec_log_parse_type
 Log types to parse.
 
enum  switchtec_log_def_type
 Log definition data types.
 
enum  switchtec_event_id
 Enumeration of all possible events.
 
enum  switchtec_event_flags
 Event control flags. More...
 
enum  switchtec_event_special
 Special event indexes numbers. More...
 
enum  switchtec_event_type
 There are three event types indicated by this enumeration: global, partition and port function.
 
enum  switchtec_fw_dlstatus
 Firmware update status. More...
 
enum  switchtec_fw_ro
 Flag which indicates if a partition is read-only or not.
 
enum  switchtec_evcntr_type_mask {
  UNSUP_REQ_ERR = 1 << 0, ECRC_ERR = 1 << 1, MALFORM_TLP_ERR = 1 << 2, RCVR_OFLOW_ERR = 1 << 3,
  CMPLTR_ABORT_ERR = 1 << 4, POISONED_TLP_ERR = 1 << 5, SURPRISE_DOWN_ERR = 1 << 6, DATA_LINK_PROTO_ERR = 1 << 7,
  HDR_LOG_OFLOW_ERR = 1 << 8, UNCOR_INT_ERR = 1 << 9, REPLAY_TMR_TIMEOUT = 1 << 10, REPLAY_NUM_ROLLOVER = 1 << 11,
  BAD_DLLP = 1 << 12, BAD_TLP = 1 << 13, RCVR_ERR = 1 << 14, RCV_FATAL_MSG = 1 << 15,
  RCV_NON_FATAL_MSG = 1 << 16, RCV_CORR_MSG = 1 << 17, NAK_RCVD = 1 << 18, RULE_TABLE_HIT = 1 << 19,
  POSTED_TLP = 1 << 20, COMP_TLP = 1 << 21, NON_POSTED_TLP = 1 << 22, ALL_ERRORS,
  ALL_TLPS = (POSTED_TLP | COMP_TLP | NON_POSTED_TLP), ALL = (1 << 23) - 1
}
 Event counter type mask (may be or-d together) More...
 

Functions

struct switchtec_dev * switchtec_open (const char *device)
 Open a Switchtec device by string. More...
 
struct switchtec_dev * switchtec_open_by_path (const char *path)
 Open a switchtec device by path. More...
 
struct switchtec_dev * switchtec_open_by_index (int index)
 Open a switchtec device by index. More...
 
struct switchtec_dev * switchtec_open_by_pci_addr (int domain, int bus, int device, int func)
 Open a switchtec device by PCI address (BDF) More...
 
struct switchtec_dev * switchtec_open_i2c (const char *path, int i2c_addr)
 Open a switchtec device behind an I2C device. More...
 
struct switchtec_dev * switchtec_open_uart (int fd)
 Open a switchtec device behind a uart device. More...
 
struct switchtec_dev * switchtec_open_eth (const char *ip, const int inst)
 Open a switchtec device over ethernet. More...
 
void switchtec_close (struct switchtec_dev *dev)
 Close a Switchtec device handle. More...
 
int switchtec_list (struct switchtec_device_info **devlist)
 List all the switchtec devices in the system. More...
 
void switchtec_list_free (struct switchtec_device_info *devlist)
 Free a list of device info structures allocated by switchtec_list() More...
 
int switchtec_get_fw_version (struct switchtec_dev *dev, char *buf, size_t buflen)
 Get the firmware version as a user readable string. More...
 
int switchtec_cmd (struct switchtec_dev *dev, uint32_t cmd, const void *payload, size_t payload_len, void *resp, size_t resp_len)
 Execute an MRPC command. More...
 
int switchtec_get_devices (struct switchtec_dev *dev, struct switchtec_status *status, int ports)
 Populate an already retrieved switchtec_status structure list with information about the devices plugged into the switch. 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...
 
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_check (struct switchtec_dev *dev, struct switchtec_event_summary *check, struct switchtec_event_summary *res)
 Check if one or more events have occurred. 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...
 
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...
 
_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...
 
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...
 
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...
 
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...
 
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_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...
 
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...
 
static int switchtec_is_gen3 (struct switchtec_dev *dev)
 Return whether a Switchtec device is a Gen 3 device.
 
static int switchtec_is_gen4 (struct switchtec_dev *dev)
 Return whether a Switchtec device is a Gen 4 device.
 
static int switchtec_is_gen5 (struct switchtec_dev *dev)
 Return whether a Switchtec device is a Gen 5 device.
 
static int switchtec_max_supported_ports (struct switchtec_dev *dev)
 Return the max number of ports of a Switchtec device.
 
static int switchtec_is_pfx (struct switchtec_dev *dev)
 Return whether a Switchtec device is PFX.
 
static int switchtec_is_pfxl (struct switchtec_dev *dev)
 Return whether a Switchtec device is PFX-L.
 
static int switchtec_is_pfxi (struct switchtec_dev *dev)
 Return whether a Switchtec device is PFX-I.
 
static int switchtec_is_pfxa (struct switchtec_dev *dev)
 Return whether a Switchtec device is PFX-A.
 
static int switchtec_is_pfx_all (struct switchtec_dev *dev)
 Return whether a Switchtec device is PFX(L/I/A).
 
static int switchtec_is_psx (struct switchtec_dev *dev)
 Return whether a Switchtec device is PSX.
 
static int switchtec_is_psxa (struct switchtec_dev *dev)
 Return whether a Switchtec device is PSX-A.
 
static int switchtec_is_psx_all (struct switchtec_dev *dev)
 Return whether a Switchtec device is PSX(A).
 
static int switchtec_is_psx_pfx_all (struct switchtec_dev *dev)
 Return whether a Switchtec device is PFX or PSX.
 
static int switchtec_is_pax (struct switchtec_dev *dev)
 Return whether a Switchtec device is PAX.
 
static int switchtec_is_paxa (struct switchtec_dev *dev)
 Return whether a Switchtec device is PAX-A.
 
static int switchtec_is_pax_all (struct switchtec_dev *dev)
 Return whether a Switchtec device is PAX(A).
 
static const char * switchtec_gen_str (struct switchtec_dev *dev)
 Return the generation string of a Switchtec device.
 
static const char * stmfd_rev_str (uint8_t rev)
 Return the revision string for Stamford Platform.
 
static const char * switchtec_rev_str (enum switchtec_rev rev)
 Return the revision string.
 
static const char * switchtec_fw_image_gen_str (struct switchtec_fw_image_info *inf)
 Return the generation string of a Switchtec fw image.
 
static const char * switchtec_variant_str (struct switchtec_dev *dev)
 Return the variant string of a Switchtec device.
 
static const char * switchtec_phase_id_str (enum switchtec_boot_phase phase_id)
 Return the phase string for a phase id.
 
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...
 
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_fw_toggle_active_partition (struct switchtec_dev *dev, int toggle_bl2, int toggle_key, int toggle_fw, int toggle_cfg)
 Toggle the active firmware partition for the main or configuration images. More...
 
int switchtec_fw_write_fd (struct switchtec_dev *dev, int img_fd, int dont_activate, int force, void(*progress_callback)(int cur, int tot))
 Write a firmware file to the switchtec device. More...
 
int switchtec_fw_write_file (struct switchtec_dev *dev, FILE *fimg, int dont_activate, int force, void(*progress_callback)(int cur, int tot))
 Write a firmware file to the switchtec device. More...
 
int switchtec_fw_read_fd (struct switchtec_dev *dev, int fd, unsigned long addr, size_t len, void(*progress_callback)(int cur, int tot))
 Read a Switchtec device's flash data into a file. More...
 
int switchtec_fw_body_read_fd (struct switchtec_dev *dev, int fd, struct switchtec_fw_image_info *info, void(*progress_callback)(int cur, int tot))
 Read a Switchtec device's flash image body into a file. More...
 
int switchtec_fw_read (struct switchtec_dev *dev, unsigned long addr, size_t len, void *buf)
 Read a Switchtec device's flash data. More...
 
void switchtec_fw_perror (const char *s, int ret)
 Print an error string to stdout. More...
 
int switchtec_fw_file_info (int fd, struct switchtec_fw_image_info *info)
 Retrieve information about a firmware image file. More...
 
int switchtec_fw_file_secure_version_newer (struct switchtec_dev *dev, int img_fd)
 Check if the secure version of an image file is newer than that of the image on device. More...
 
const char * switchtec_fw_image_type (const struct switchtec_fw_image_info *info)
 Return a string describing the type of a firmware image. More...
 
struct switchtec_fw_part_summaryswitchtec_fw_part_summary (struct switchtec_dev *dev)
 Return firmware summary information structure for the flash partitfons in the device. More...
 
void switchtec_fw_part_summary_free (struct switchtec_fw_part_summary *summary)
 Free a firmware part summary data structure. More...
 
int switchtec_fw_img_write_hdr (int fd, struct switchtec_fw_image_info *info)
 Write the header for a Switchtec firmware image file. More...
 
int switchtec_fw_is_boot_ro (struct switchtec_dev *dev)
 Check if the boot partition is marked as read-only. More...
 
int switchtec_fw_set_boot_ro (struct switchtec_dev *dev, enum switchtec_fw_ro ro)
 Set or clear a boot partition's read-only flag. More...
 
enum switchtec_gen switchtec_fw_version_to_gen (unsigned int version)
 Extract generation information from FW version number. 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_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...
 
gasptr_t switchtec_gas_map (struct switchtec_dev *dev, int writeable, size_t *map_size)
 Map the GAS and return a pointer to access the gas. More...
 
void switchtec_gas_unmap (struct switchtec_dev *dev, gasptr_t map)
 Unmap the GAS region mapped with. More...
 
int switchtec_diag_cross_hair_enable (struct switchtec_dev *dev, int lane_id)
 Enable cross hair on specified lane. More...
 
int switchtec_diag_cross_hair_disable (struct switchtec_dev *dev)
 Disable active cross hair. More...
 
int switchtec_diag_cross_hair_get (struct switchtec_dev *dev, int start_lane_id, int num_lanes, struct switchtec_diag_cross_hair *res)
 Disable active cross hair. More...
 
int switchtec_diag_eye_set_mode (struct switchtec_dev *dev, enum switchtec_diag_eye_data_mode mode)
 Set the data mode for the next Eye Capture. More...
 
int switchtec_diag_eye_start (struct switchtec_dev *dev, int lane_mask[4], struct range *x_range, struct range *y_range, int step_interval)
 Start a PCIe Eye Capture. More...
 
int switchtec_diag_eye_fetch (struct switchtec_dev *dev, double *pixels, size_t pixel_cnt, int *lane_id)
 Start a PCIe Eye Capture. More...
 
int switchtec_diag_eye_cancel (struct switchtec_dev *dev)
 Cancel in-progress eye capture. More...
 
int switchtec_diag_loopback_set (struct switchtec_dev *dev, int port_id, int enable, enum switchtec_diag_ltssm_speed ltssm_speed)
 Setup Loopback Mode. More...
 
int switchtec_diag_loopback_get (struct switchtec_dev *dev, int port_id, int *enabled, enum switchtec_diag_ltssm_speed *ltssm_speed)
 Setup Loopback Mode. More...
 
int switchtec_diag_pattern_gen_set (struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern type)
 Setup Pattern Generator. More...
 
int switchtec_diag_pattern_gen_get (struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern *type)
 Get Pattern Generator set on port. More...
 
int switchtec_diag_pattern_mon_set (struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern type)
 Setup Pattern Monitor. More...
 
int switchtec_diag_pattern_mon_get (struct switchtec_dev *dev, int port_id, int lane_id, enum switchtec_diag_pattern *type, unsigned long long *err_cnt)
 Get Pattern Monitor. More...
 
int switchtec_diag_pattern_inject (struct switchtec_dev *dev, int port_id, unsigned int err_cnt)
 Inject error into pattern generator. More...
 
int switchtec_diag_rcvr_obj (struct switchtec_dev *dev, int port_id, int lane_id, enum switchtec_diag_link link, struct switchtec_rcvr_obj *res)
 Get the receiver object. More...
 
int switchtec_diag_rcvr_ext (struct switchtec_dev *dev, int port_id, int lane_id, enum switchtec_diag_link link, struct switchtec_rcvr_ext *res)
 Get the Extended Receiver Object. More...
 
int switchtec_diag_port_eq_tx_coeff (struct switchtec_dev *dev, int port_id, enum switchtec_diag_end end, enum switchtec_diag_link link, struct switchtec_port_eq_coeff *res)
 Get the port equalization TX coefficients. More...
 
int switchtec_diag_port_eq_tx_table (struct switchtec_dev *dev, int port_id, enum switchtec_diag_link link, struct switchtec_port_eq_table *res)
 Get the far end TX equalization table. More...
 
int switchtec_diag_port_eq_tx_fslf (struct switchtec_dev *dev, int port_id, int lane_id, enum switchtec_diag_end end, enum switchtec_diag_link link, struct switchtec_port_eq_tx_fslf *res)
 Get the equalization FS/LF. More...
 
int switchtec_diag_perm_table (struct switchtec_dev *dev, struct switchtec_mrpc table[MRPC_MAX_ID])
 Get the permission table. More...
 
int switchtec_diag_refclk_ctl (struct switchtec_dev *dev, int stack_id, bool en)
 Control the refclk output for a stack. More...
 
int switchtec_diag_ltssm_log (struct switchtec_dev *dev, int port, int *log_count, struct switchtec_diag_ltssm_log *log_data)
 Get the LTSSM log of a port on a switchtec device. More...
 

Variables

static const float switchtec_gen_transfers [] = {0, 2.5, 5, 8, 16, 32}
 Number of GT/s capable for each PCI generation or link_rate.
 
static const float switchtec_gen_datarate [] = {0, 250, 500, 985, 1969, 3938}
 Number of GB/s capable for each PCI generation or link_rate.
 

Detailed Description

Main Switchtec header.

Definition in file switchtec.h.

Enumeration Type Documentation

◆ switchtec_evcntr_type_mask

Event counter type mask (may be or-d together)

Enumerator
UNSUP_REQ_ERR 

Unsupported Request Error.

ECRC_ERR 

ECRC Error.

MALFORM_TLP_ERR 

Malformed TLP Error.

RCVR_OFLOW_ERR 

Receiver Overflow Error.

CMPLTR_ABORT_ERR 

Completer Abort Error.

POISONED_TLP_ERR 

Poisoned TLP Error.

SURPRISE_DOWN_ERR 

Surprise Down Error.

DATA_LINK_PROTO_ERR 

Data Link Protocol Error.

HDR_LOG_OFLOW_ERR 

Header Log Overflow Error.

UNCOR_INT_ERR 

Uncorrectable Internal Error.

REPLAY_TMR_TIMEOUT 

Replay Timer Timeout.

REPLAY_NUM_ROLLOVER 

Replay Number Rollover.

BAD_DLLP 

Bad DLLP.

BAD_TLP 

Bad TLP.

RCVR_ERR 

Receiver Error.

RCV_FATAL_MSG 

Receive FATAL Error Message.

RCV_NON_FATAL_MSG 

Receive Non-FATAL Error Message.

RCV_CORR_MSG 

Receive Correctable Error Message.

NAK_RCVD 

NAK Received.

RULE_TABLE_HIT 

Rule Search Table Rule Hit.

POSTED_TLP 

Posted TLP.

COMP_TLP 

Completion TLP.

NON_POSTED_TLP 

Non-Posted TLP.

ALL_ERRORS 

Mask indicating all possible errors.

ALL_TLPS 

Mask indicating all TLP types.

ALL 

Mask indicating all event types.

Definition at line 939 of file switchtec.h.

◆ switchtec_event_flags

Event control flags.

See also
switchtec_event_ctl()

Definition at line 791 of file switchtec.h.

◆ switchtec_event_special

Special event indexes numbers.

For specifying the local partition or all partitions/ports.

See also
switchtec_event_ctl()

Definition at line 810 of file switchtec.h.

◆ switchtec_fw_dlstatus

Firmware update status.

See also
switchtec_fw_dlstatus()

Definition at line 848 of file switchtec.h.

◆ switchtec_log_type

Describe the type of logs too dump.

See also
switchtec_log_to_file()

Definition at line 229 of file switchtec.h.

Function Documentation

◆ switchtec_diag_cross_hair_disable()

int switchtec_diag_cross_hair_disable ( struct switchtec_dev *  dev)

Disable active cross hair.

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

Definition at line 69 of file diag.c.

◆ switchtec_diag_cross_hair_enable()

int switchtec_diag_cross_hair_enable ( struct switchtec_dev *  dev,
int  lane_id 
)

Enable cross hair on specified lane.

Parameters
[in]devSwitchtec device handle
[in]lane_idLane to enable, or SWITCHTEC_DIAG_CROSS_HAIR_ALL_LANES for all lanes.
Returns
0 on success, error code on failure

Definition at line 52 of file diag.c.

◆ switchtec_diag_cross_hair_get()

int switchtec_diag_cross_hair_get ( struct switchtec_dev *  dev,
int  start_lane_id,
int  num_lanes,
struct switchtec_diag_cross_hair res 
)

Disable active cross hair.

Parameters
[in]devSwitchtec device handle
[in]start_lane_idStart lane ID to get
[in]num_lanesNumber of lanes to get
[out]resResulting cross hair data
Returns
0 on success, error code on failure

Definition at line 87 of file diag.c.

◆ switchtec_diag_eye_cancel()

int switchtec_diag_eye_cancel ( struct switchtec_dev *  dev)

Cancel in-progress eye capture.

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

Definition at line 306 of file diag.c.

◆ switchtec_diag_eye_fetch()

int switchtec_diag_eye_fetch ( struct switchtec_dev *  dev,
double *  pixels,
size_t  pixel_cnt,
int *  lane_id 
)

Start a PCIe Eye Capture.

Parameters
[in]devSwitchtec device handle
[out]pixelsResulting pixel data
[in]pixel_cntSpace in pixel array
[out]lane_idThe lane for the resulting pixels
Returns
number of pixels fetched on success, error code on failure

pixel_cnt needs to be greater than 62 in raw mode or 496 in ratio mode, otherwise data will be lost and the number of pixels fetched will be greater than the space in the pixel buffer.

Definition at line 246 of file diag.c.

◆ switchtec_diag_eye_set_mode()

int switchtec_diag_eye_set_mode ( struct switchtec_dev *  dev,
enum switchtec_diag_eye_data_mode  mode 
)

Set the data mode for the next Eye Capture.

Parameters
[in]devSwitchtec device handle
[in]modeMode to use (raw or ratio)
Returns
0 on success, error code on failure

Definition at line 168 of file diag.c.

◆ switchtec_diag_eye_start()

int switchtec_diag_eye_start ( struct switchtec_dev *  dev,
int  lane_mask[4],
struct range x_range,
struct range y_range,
int  step_interval 
)

Start a PCIe Eye Capture.

Parameters
[in]devSwitchtec device handle
[in]lane_maskBitmap of the lanes to capture
[in]x_rangeTime range: start should be between 0 and 63, end between start and 63.
[in]y_rangeVoltage range: start should be between -255 and 255, end between start and 255.
[in]step_intervalSampling time in milliseconds for each step
Returns
0 on success, error code on failure

Definition at line 191 of file diag.c.

◆ switchtec_diag_loopback_get()

int switchtec_diag_loopback_get ( struct switchtec_dev *  dev,
int  port_id,
int *  enabled,
enum switchtec_diag_ltssm_speed *  ltssm_speed 
)

Setup Loopback Mode.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[out]enabledSet of enum switchtec_diag_loopback_enable indicating which loopback modes are enabled
[out]ltssm_speedLTSSM loopback max speed
Returns
0 on succes, error code on failure

Definition at line 384 of file diag.c.

◆ switchtec_diag_loopback_set()

int switchtec_diag_loopback_set ( struct switchtec_dev *  dev,
int  port_id,
int  enable,
enum switchtec_diag_ltssm_speed  ltssm_speed 
)

Setup Loopback Mode.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]enableAny enum switchtec_diag_loopback_enable flags or'd together to enable specific loopback modes
[in]ltssm_speedLTSSM loopback max speed
Returns
0 on success, error code on failure

Definition at line 334 of file diag.c.

◆ switchtec_diag_ltssm_log()

int switchtec_diag_ltssm_log ( struct switchtec_dev *  dev,
int  port,
int *  log_count,
struct switchtec_diag_ltssm_log log_data 
)

Get the LTSSM log of a port on a switchtec device.

Parameters
[in]devSwitchtec device handle
[in]portSwitchtec Port
[in,out]log_countnumber of log entries
[out]logA pointer to an array containing the log

Definition at line 917 of file diag.c.

◆ switchtec_diag_pattern_gen_get()

int switchtec_diag_pattern_gen_get ( struct switchtec_dev *  dev,
int  port_id,
enum switchtec_diag_pattern *  type 
)

Get Pattern Generator set on port.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[out]typePattern type to enable
Returns
0 on success, error code on failure

Definition at line 462 of file diag.c.

◆ switchtec_diag_pattern_gen_set()

int switchtec_diag_pattern_gen_set ( struct switchtec_dev *  dev,
int  port_id,
enum switchtec_diag_pattern  type 
)

Setup Pattern Generator.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]typePattern type to enable
Returns
0 on success, error code on failure

Definition at line 442 of file diag.c.

◆ switchtec_diag_pattern_inject()

int switchtec_diag_pattern_inject ( struct switchtec_dev *  dev,
int  port_id,
unsigned int  err_cnt 
)

Inject error into pattern generator.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]err_cntNumber of errors seen

Injects up to err_cnt errors into each lane of the TX port. It's recommended that the err_cnt be less than 1000, otherwise the firmware runs the risk of consuming too many resources and crashing.

Returns
0 on success, error code on failure

Definition at line 551 of file diag.c.

◆ switchtec_diag_pattern_mon_get()

int switchtec_diag_pattern_mon_get ( struct switchtec_dev *  dev,
int  port_id,
int  lane_id,
enum switchtec_diag_pattern *  type,
unsigned long long *  err_cnt 
)

Get Pattern Monitor.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[out]typePattern type to enable
[out]err_cntNumber of errors seen
Returns
0 on success, error code on failure

Definition at line 512 of file diag.c.

◆ switchtec_diag_pattern_mon_set()

int switchtec_diag_pattern_mon_set ( struct switchtec_dev *  dev,
int  port_id,
enum switchtec_diag_pattern  type 
)

Setup Pattern Monitor.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]typePattern type to enable
Returns
0 on success, error code on failure

Definition at line 491 of file diag.c.

◆ switchtec_diag_perm_table()

int switchtec_diag_perm_table ( struct switchtec_dev *  dev,
struct switchtec_mrpc  table[MRPC_MAX_ID] 
)

Get the permission table.

Parameters
[in]devSwitchtec device handle
[out]tableResulting MRPC permission table
Returns
0 on success, error code on failure

Definition at line 862 of file diag.c.

◆ switchtec_diag_port_eq_tx_coeff()

int switchtec_diag_port_eq_tx_coeff ( struct switchtec_dev *  dev,
int  port_id,
enum switchtec_diag_end  end,
enum switchtec_diag_link  link,
struct switchtec_port_eq_coeff res 
)

Get the port equalization TX coefficients.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]endGet coefficents for the Local or the Far End
[out]resResulting port equalization coefficients
Returns
0 on success, error code on failure

Definition at line 633 of file diag.c.

◆ switchtec_diag_port_eq_tx_fslf()

int switchtec_diag_port_eq_tx_fslf ( struct switchtec_dev *  dev,
int  port_id,
int  lane_id,
enum switchtec_diag_end  end,
enum switchtec_diag_link  link,
struct switchtec_port_eq_tx_fslf res 
)

Get the equalization FS/LF.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]lane_idPhysical port ID
[in]endGet coefficents for the Local or the Far End
[out]resResulting FS/LF values
Returns
0 on success, error code on failure

Definition at line 755 of file diag.c.

◆ switchtec_diag_port_eq_tx_table()

int switchtec_diag_port_eq_tx_table ( struct switchtec_dev *  dev,
int  port_id,
enum switchtec_diag_link  link,
struct switchtec_port_eq_table res 
)

Get the far end TX equalization table.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[out]resResulting port equalization table
Returns
0 on success, error code on failure

Definition at line 695 of file diag.c.

◆ switchtec_diag_rcvr_ext()

int switchtec_diag_rcvr_ext ( struct switchtec_dev *  dev,
int  port_id,
int  lane_id,
enum switchtec_diag_link  link,
struct switchtec_rcvr_ext res 
)

Get the Extended Receiver Object.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]lane_idLane ID
[in]linkCurrent or previous link-up
[out]resResulting receiver object
Returns
0 on success, error code on failure

Definition at line 817 of file diag.c.

◆ switchtec_diag_rcvr_obj()

int switchtec_diag_rcvr_obj ( struct switchtec_dev *  dev,
int  port_id,
int  lane_id,
enum switchtec_diag_link  link,
struct switchtec_rcvr_obj res 
)

Get the receiver object.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]lane_idLane ID
[in]linkCurrent or previous link-up
[out]resResulting receiver object
Returns
0 on success, error code on failure

Definition at line 578 of file diag.c.

◆ switchtec_diag_refclk_ctl()

int switchtec_diag_refclk_ctl ( struct switchtec_dev *  dev,
int  stack_id,
bool  en 
)

Control the refclk output for a stack.

Parameters
[in]devSwitchtec device handle
[in]stack_idStack ID to control the refclk of
[in]enSet to true to enable, false to disable
Returns
0 on success, error code on failure

Definition at line 899 of file diag.c.