Switchtec Userspace PROJECT_NUMBER = 4.2
Loading...
Searching...
No Matches
switchtec.h File Reference

Main Switchtec header. More...

#include "mrpc.h"
#include "bind.h"
#include "portable.h"
#include "registers.h"
#include "utils.h"
#include "inject.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  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_gpio
struct  switchtec_gpio_sts_out
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_rem_port_eq_coeff
struct  switchtec_port_eq_coeff_in
struct  switchtec_port_eq_table_in
struct  switchtec_port_eq_table
struct  switchtec_gen5_port_eq_table
struct  switchtec_port_eq_tx_fslf
struct  switchtec_port_eq_tx_fslf_out
struct  switchtec_port_eq_tx_fslf_in
struct  switchtec_rcvr_ext
struct  switchtec_mrpc
struct  switchtec_gen5_diag_eye_status_in
struct  switchtec_gen5_diag_eye_status_out
struct  switchtec_gen5_diag_eye_read_in
struct  switchtec_gen5_diag_eye_read_out
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  switchtec_rev
 Device hardware revision.
enum  switchtec_boot_phase
 Device boot phase.
enum  switchtec_parition_types
 Device parition types GEN5.
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...
enum  lane_eq_dump_type_enum { LANE_EQ_DUMP_TYPE_CURR , LANE_EQ_DUMP_TYPE_PREV , LANE_EQ_DUMP_TYPE_NUM }
enum  link_rate_enum {
  PCIE_LINK_RATE_INV = 0 , PCIE_LINK_RATE_GEN1 = 1 , PCIE_LINK_RATE_GEN2 = 2 , PCIE_LINK_RATE_GEN3 = 3 ,
  PCIE_LINK_RATE_GEN4 = 4 , PCIE_LINK_RATE_GEN5 = 5 , PCIE_LINK_RATE_NUM = 5
}

Functions

struct switchtec_dev * switchtec_open (const char *device)
 Open a Switchtec device by string.
void switchtec_close (struct switchtec_dev *dev)
 Close a Switchtec device handle.
void switchtec_list_free (struct switchtec_device_info *devlist)
 Free a list of device info structures allocated by switchtec_list().
int switchtec_get_fw_version (struct switchtec_dev *dev, char *buf, size_t buflen)
 Get the firmware version as a user readable string.
int switchtec_get_device_version (struct switchtec_dev *dev, int *res)
 Get the minor version number as a user readable int.
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.
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.
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.
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.
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.
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.
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.
int switchtec_event_wait (struct switchtec_dev *dev, int timeout_ms)
 Wait for any event to occur (typically just an interrupt).
_PURE const char * switchtec_name (struct switchtec_dev *dev)
 Get the string that was used to open the deviec.
_PURE int switchtec_partition (struct switchtec_dev *dev)
 Get the partiton number of the device that was opened.
_PURE int switchtec_device_id (struct switchtec_dev *dev)
 Get the device id of the device.
_PURE enum switchtec_gen switchtec_gen (struct switchtec_dev *dev)
 Get the generation of the device.
_PURE enum switchtec_variant switchtec_variant (struct switchtec_dev *dev)
 Get the variant type of the device.
_PURE enum switchtec_boot_phase switchtec_boot_phase (struct switchtec_dev *dev)
 Get boot phase of the device.
int switchtec_echo (struct switchtec_dev *dev, uint32_t input, uint32_t *output)
 Perform an MRPC echo command.
int switchtec_hard_reset (struct switchtec_dev *dev)
 Perform an MRPC hard reset command.
int switchtec_status (struct switchtec_dev *dev, struct switchtec_status **status)
 Get the status of all the ports on a switchtec device.
void switchtec_status_free (struct switchtec_status *status, int ports)
 Free a list of status structures allocated by switchtec_status().
int switchtec_get_device_info (struct switchtec_dev *dev, enum switchtec_boot_phase *phase, enum switchtec_gen *gen, enum switchtec_rev *rev)
 Get device generation, revision, and boot phase info.
const char * switchtec_strerror (void)
 Return a message coresponding to the last error.
void switchtec_perror (const char *str)
 Print an error string to stdout.
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.
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.
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.
float switchtec_die_temp (struct switchtec_dev *dev)
 Get the die temperature of the switchtec device.
int switchtec_die_temps (struct switchtec_dev *dev, int nr_sensor, float *sensor_readings)
 Get the die temperature sensor readings of the switchtec device.
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.
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.
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.
int switchtec_inject_err_dllp (struct switchtec_dev *dev, int phys_port_id, int data)
 Return Link error injection command outputs for DLLP, DLLP_CRC, LCRC, SEQ_NUM, ACK_NACK, CTO.
int switchtec_inject_err_dllp_crc (struct switchtec_dev *dev, int phys_port_id, int enable, uint16_t rate)
 Inject a DLLP CRC error into a physical port.
int switchtec_inject_err_tlp_lcrc (struct switchtec_dev *dev, int phys_port_id, int enable, uint8_t rate)
 Inject a TLP LCRC error into a physical port.
int switchtec_inject_err_tlp_seq_num (struct switchtec_dev *dev, int phys_port_id)
 Inject a TLP Sequence Number error into a physical port.
int switchtec_inject_err_ack_nack (struct switchtec_dev *dev, int phys_port_id, uint16_t seq_num, uint8_t count)
 Inject an ACK to NACK error into a physical port.
int switchtec_inject_err_cto (struct switchtec_dev *dev, int phys_port_id)
 Inject Credit Timeout error into a physical port.
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 * 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.
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.
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.
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.
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.
int switchtec_fw_set_redundant_flag (struct switchtec_dev *dev, int keyman, int riot, int bl2, int cfg, int fw, int set)
 Set the redundant image flag for the specified image types.
int switchtec_fw_toggle_active_partition (struct switchtec_dev *dev, int toggle_bl2, int toggle_key, int toggle_fw, int toggle_cfg, int toggle_riotcore)
 Toggle the active firmware partition for the main or configuration images.
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.
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.
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.
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.
int switchtec_fw_read (struct switchtec_dev *dev, unsigned long addr, size_t len, void *buf)
 Read a Switchtec device's flash data.
void switchtec_fw_perror (const char *s, int ret)
 Print an error string to stdout.
int switchtec_fw_file_info (int fd, struct switchtec_fw_image_info *info)
 Retrieve information about a firmware image file.
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.
const char * switchtec_fw_image_type (const struct switchtec_fw_image_info *info)
 Return a string describing the type of a firmware image.
struct switchtec_fw_part_summary * switchtec_fw_part_summary (struct switchtec_dev *dev)
 Return firmware summary information structure for the flash partitfons in the device.
void switchtec_fw_part_summary_free (struct switchtec_fw_part_summary *summary)
 Free a firmware part summary data structure.
int switchtec_fw_img_write_hdr (int fd, struct switchtec_fw_image_info *info)
 Write the header for a Switchtec firmware image file.
int switchtec_fw_is_boot_ro (struct switchtec_dev *dev)
 Check if the boot partition is marked as read-only.
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.
enum switchtec_gen switchtec_fw_version_to_gen (unsigned int version)
 Extract generation information from FW version number.
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.
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.
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.
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.
int switchtec_get_gpio (struct switchtec_dev *dev, int pin_id, int *gpio_val)
 Get the GPIO pin value.
int switchtec_set_gpio (struct switchtec_dev *dev, int pin_id, int gpio_val)
 Set the GPIO pin value.
int switchtec_get_gpio_direction_cfg (struct switchtec_dev *dev, int pin_id, int *direction)
 Get the GPIO pin direction.
int switchtec_get_gpio_polarity_cfg (struct switchtec_dev *dev, int pin_id, int *polarity)
 Get the GPIO pin polarity.
int switchtec_en_dis_interrupt (struct switchtec_dev *dev, int pin_id, int en)
 Enable/Disable the GPIO pin interrupt.
int switchtec_get_all_pin_sts (struct switchtec_dev *dev, uint32_t *values)
 Get all GPIO pin status.
int switchtec_evcntr_type_count (void)
 Get the number of event counter types.
const char * switchtec_evcntr_type_str (int *type_mask)
 Get a string for the event indicated by lowest bit set in the type_mask.
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.
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.
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.
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.
int switchtec_evcntr_wait (struct switchtec_dev *dev, int timeout_ms)
 Block until any event counter has reached its threshold.
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.
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.
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.
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.
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.
uint64_t switchtec_bwcntr_tot (struct switchtec_bwcntr_dir *d)
 Get the total.
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.
int switchtec_lat_setup (struct switchtec_dev *dev, int egress_port_id, int ingress_port_id, int clear)
 Setup a latency counter.
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.
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.
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.
void switchtec_gas_unmap (struct switchtec_dev *dev, gasptr_t map)
 Unmap the GAS region mapped with.
int switchtec_diag_cross_hair_enable (struct switchtec_dev *dev, int lane_id)
 Enable cross hair on specified lane.
int switchtec_diag_cross_hair_disable (struct switchtec_dev *dev)
 Disable active cross hair.
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.
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.
int switchtec_diag_eye_read (struct switchtec_dev *dev, int lane_id, int bin, int *num_phases, double *ber_data)
 Start a PCIe Eye Read Gen5.
int switchtec_diag_eye_start (struct switchtec_dev *dev, int lane_mask[4], struct range *x_range, struct range *y_range, int step_interval, int capture_depth)
 Start a PCIe Eye Capture.
int switchtec_diag_eye_fetch (struct switchtec_dev *dev, double *pixels, size_t pixel_cnt, int *lane_id)
 Start a PCIe Eye Capture.
int switchtec_diag_eye_cancel (struct switchtec_dev *dev)
 Cancel in-progress eye capture.
int switchtec_diag_loopback_set (struct switchtec_dev *dev, int port_id, int enable, int enable_parallel, int enable_external, int enable_ltssm, enum switchtec_diag_ltssm_speed ltssm_speed)
 Setup Loopback Mode.
int switchtec_diag_loopback_get (struct switchtec_dev *dev, int port_id, int *enabled, enum switchtec_diag_ltssm_speed *ltssm_speed)
 Setup Loopback Mode.
int switchtec_diag_pattern_gen_set (struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern type, enum switchtec_diag_pattern_link_rate link_speed)
 Setup Pattern Generator.
int switchtec_diag_pattern_gen_get (struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern *type)
 Get Pattern Generator set on port.
int switchtec_diag_pattern_mon_set (struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern type)
 Setup Pattern Monitor.
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.
int switchtec_diag_pattern_inject (struct switchtec_dev *dev, int port_id, unsigned int err_cnt)
 Inject error into pattern generator.
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.
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.
int switchtec_diag_port_eq_tx_coeff (struct switchtec_dev *dev, int port_id, int prev_speed, enum switchtec_diag_end end, enum switchtec_diag_link link, struct switchtec_port_eq_coeff *res)
 Get the port equalization TX coefficients.
int switchtec_diag_port_eq_tx_table (struct switchtec_dev *dev, int port_id, int prev_speed, enum switchtec_diag_link link, struct switchtec_port_eq_table *res)
 Get the far end TX equalization table.
int switchtec_diag_port_eq_tx_fslf (struct switchtec_dev *dev, int port_id, int prev_speed, 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.
int switchtec_diag_perm_table (struct switchtec_dev *dev, struct switchtec_mrpc table[MRPC_MAX_ID])
 Get the permission table.
int switchtec_diag_refclk_ctl (struct switchtec_dev *dev, int stack_id, bool en)
 Control the refclk output for a stack.
int switchtec_diag_refclk_status (struct switchtec_dev *dev, uint8_t *stack_info)
 Get the status of all stacks of the refclk.
int switchtec_diag_ltssm_clear (struct switchtec_dev *dev, int port)
 Call the LTSSM clear MRPC command.
int switchtec_diag_ltssm_log (struct switchtec_dev *dev, int port, int *log_count, struct switchtec_diag_ltssm_log *log_data)
 Determine the generation and call the related LTSSM log func.
int switchtec_aer_event_gen (struct switchtec_dev *dev, int port_id, int aer_error_id, int trigger_event)
 Call the aer event gen function to generate AER events.

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

◆ lane_eq_dump_type_enum

Enumerator
LANE_EQ_DUMP_TYPE_CURR 

Current settings.

LANE_EQ_DUMP_TYPE_PREV 

Previous link-up settings.

LANE_EQ_DUMP_TYPE_NUM 

Total number of dump types.

Definition at line 1303 of file switchtec.h.

◆ link_rate_enum

Enumerator
PCIE_LINK_RATE_INV 

Invalid.

PCIE_LINK_RATE_GEN1 

Gen1, supports 2.5GT/s.

PCIE_LINK_RATE_GEN2 

Gen2, supports 2.5GT/s, 5GT/s.

PCIE_LINK_RATE_GEN3 

Gen3, supports 2.5GT/s, 5GT/s, 8GT/s.

PCIE_LINK_RATE_GEN4 

Gen4, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s.

PCIE_LINK_RATE_GEN5 

Gen5, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s, 32GT/s.

PCIE_LINK_RATE_NUM 

Total number of PCIe generations.

Definition at line 1309 of file switchtec.h.

◆ 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 1071 of file switchtec.h.

◆ switchtec_event_flags

Event control flags.

See also
switchtec_event_ctl()

Definition at line 893 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 912 of file switchtec.h.

◆ switchtec_fw_dlstatus

Firmware update status.

See also
switchtec_fw_dlstatus()

Definition at line 950 of file switchtec.h.

◆ switchtec_log_type

Describe the type of logs too dump.

See also
switchtec_log_to_file()

Definition at line 211 of file switchtec.h.

Function Documentation

◆ switchtec_aer_event_gen()

int switchtec_aer_event_gen ( struct switchtec_dev * dev,
int port_id,
int aer_error_id,
int trigger_event )

Call the aer event gen function to generate AER events.

Parameters
[in]devSwitchtec device handle
[in]portSwitchtec Port
[in]aer_error_idaer error bit
[out]trigger_eventOne of the trigger events

Definition at line 1786 of file diag.c.

◆ 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 70 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 53 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 88 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 412 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 352 of file diag.c.

◆ switchtec_diag_eye_read()

int switchtec_diag_eye_read ( struct switchtec_dev * dev,
int lane_id,
int bin,
int * num_phases,
double * ber_data )

Start a PCIe Eye Read Gen5.

Parameters
[in]devSwitchtec device handle
[in]lane_idlane_id
[in]binbin
[in]num_phasespointer to the number of phases
[in]ber_datapointer to the Ber data
Returns
0 on success, error code on failure

Definition at line 242 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 221 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,
int capture_depth )

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 282 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 568 of file diag.c.

◆ switchtec_diag_loopback_set()

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

Setup Loopback Mode.

Parameters
[in]devSwitchtec device handle
[in]port_idPhysical port ID
[in]enableEnable bitmap - Gen 4
[in]enable_parallelEnable the parallel SERDES loopback - Gen 5
[in]enable_externalEnable the external physical loopback - Gen 5
[in]enable_ltssmEnable the ltssm loopback
[in]ltssm_speedLTSSM loopback max speed
Returns
0 on success, error code on failure

Definition at line 534 of file diag.c.

◆ switchtec_diag_ltssm_clear()

int switchtec_diag_ltssm_clear ( struct switchtec_dev * dev,
int port )

Call the LTSSM clear MRPC command.

Parameters
[in]devSwitchtec device handle
[in]portSwitchtec Port

Definition at line 1741 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 )

Determine the generation and call the related LTSSM log func.

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 1724 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 659 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,
enum switchtec_diag_pattern_link_rate link_speed )

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 635 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 748 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 709 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 688 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 1369 of file diag.c.

◆ switchtec_diag_port_eq_tx_coeff()

int switchtec_diag_port_eq_tx_coeff ( struct switchtec_dev * dev,
int port_id,
int prev_speed,
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 1002 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 prev_speed,
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 1294 of file diag.c.

◆ switchtec_diag_port_eq_tx_table()

int switchtec_diag_port_eq_tx_table ( struct switchtec_dev * dev,
int port_id,
int prev_speed,
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 1144 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 1324 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 775 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 1406 of file diag.c.

◆ switchtec_diag_refclk_status()

int switchtec_diag_refclk_status ( struct switchtec_dev * dev,
uint8_t * stack_info )

Get the status of all stacks of the refclk.

Parameters
[in]devSwitchtec device handle
[in]stack_infoPointer to the stack information
Returns
0 on success, error code on failure

Definition at line 1422 of file diag.c.

◆ switchtec_inject_err_ack_nack()

int switchtec_inject_err_ack_nack ( struct switchtec_dev * dev,
int phys_port_id,
uint16_t seq_num,
uint8_t count )

Inject an ACK to NACK error into a physical port.

Parameters
[in]devSwitchtec device handle
[in]phys_port_idPhysical port id
[in]seq_numSequence Number of ACK to be changed to a NACK (0-4095)
[in]countNumber of times to replace ACK with NACK (0-255)
Returns
0 on success, or a negative value on failure

Definition at line 1938 of file diag.c.

◆ switchtec_inject_err_cto()

int switchtec_inject_err_cto ( struct switchtec_dev * dev,
int phys_port_id )

Inject Credit Timeout error into a physical port.

Parameters
[in]devSwitchtec device handle
[in]phys_port_idPhysical port id
Returns
0 on success, or a negative value on failure

Definition at line 1960 of file diag.c.

◆ switchtec_inject_err_dllp()

int switchtec_inject_err_dllp ( struct switchtec_dev * dev,
int phys_port_id,
int data )

Return Link error injection command outputs for DLLP, DLLP_CRC, LCRC, SEQ_NUM, ACK_NACK, CTO.

Return Link error injection command outputs for DLLP, DLLP_CRC, LCRC, SEQ_NUM, ACK_NACK, CTO.

Parameters
[in]devSwitchtec device handle
[in]phys_port_idPhysical port id
[in]dataDLLP data
Returns
0 on success, or a negative value on failure

Definition at line 1814 of file diag.c.

◆ switchtec_inject_err_dllp_crc()

int switchtec_inject_err_dllp_crc ( struct switchtec_dev * dev,
int phys_port_id,
int enable,
uint16_t rate )

Inject a DLLP CRC error into a physical port.

Parameters
[in]devSwitchtec device handle
[in]phys_port_idPhysical port id
[in]enableEnable DLLP CRC error injection
[in]rateRate of the error injection
Returns
0 on success, or a negative value on failure

Definition at line 1837 of file diag.c.

◆ switchtec_inject_err_tlp_lcrc()

int switchtec_inject_err_tlp_lcrc ( struct switchtec_dev * dev,
int phy_port,
int enable,
uint8_t rate )

Inject a TLP LCRC error into a physical port.

Parameters
[in]devSwitchtec device handle
[in]phy_portPhysical port id
[in]rateRate of the error injection
Returns
0 on success, or a negative value on failure

Definition at line 1896 of file diag.c.

◆ switchtec_inject_err_tlp_seq_num()

int switchtec_inject_err_tlp_seq_num ( struct switchtec_dev * dev,
int phys_port_id )

Inject a TLP Sequence Number error into a physical port.

Parameters
[in]devSwitchtec device handle
[in]phys_port_idPhysical port id
Returns
0 on success, or a negative value on failure

Definition at line 1917 of file diag.c.