Velocity Userspace
Functions
diag.c File Reference

Switchtec diagnostic functions. More...

#include "switchtec_priv.h"
#include "switchtec/diag.h"
#include "switchtec/endian.h"
#include "switchtec/switchtec.h"
#include "switchtec/utils.h"
#include <errno.h>
#include <math.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
Include dependency graph for diag.c:

Go to the source code of this file.

Functions

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_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_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_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...
 

Detailed Description

Switchtec diagnostic functions.

Definition in file diag.c.

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.