# Credo SDK function list
## Description of changes
- Each seconday header below is a capability domain. All the functions of a capability domain are prefixed with the name of said capability (except for SerDes). All third level headers are there to provide separation by features for clarity.
- I have removed the ability of `CredoLaneConfig` as it is something I believe to be to dependent on the chip. Instead users should just set the SerDes explicitly they need for the lane to work.
- Reorganized to put things related cl
:pencil: help me fix some of the remaining troublesome areas in SerDes Capabilities
## SDK
Top level information that is pertinent to everything below it
### Information
Get basic information about the sdk
```c
uint32_t sdk_get_rev(void);
```
### Management
Basic creation and destruction of the sdk which holds driver and logging information
```c
ErrorCodes_t sdk_create(const CredoSdkConfig_t* config, CredoSdk_t** sdk);
ErrorCodes_t sdk_destroy(CredoSdk_t* sdk);
```
### Driver
These are extra functions for those able to use sequential read/write operations (e.g, fw_load)
```c
void sdk_set_burst_read(CredoSdk_t* sdk, CredoReadRegisterBurst_t burst_read_func);
void sdk_set_burst_write(CredoSdk_t* sdk, CredoWriteRegisterBurst_t burst_write_func);
```
### Logging
Additional information users can get about logging
```c
void sdk_set_log_level(CredoSdk_t* sdk, int max_level);
int sdk_get_log_level(CredoSdk_t* sdk);
```
### Chip library
Allow loading of chip sdk dynamically at runtime
```c
ErrorCodes_t sdk_load_chip_lib(const char* hal_file);
```
## Device
These are the specific devices of the chip
### Management
Creation and deletion of a device with user information about what kind of device it is.
```c
ErrorCodes_t device_create(CredoSdk_t* sdk, uint32_t device_type, CredoDevice_t** device);
ErrorCodes_t device_destroy(CredoDevice_t* device);
```
### Information / Access
```c
ErrorCodes_t device_get_slice_count(CredoDevice_t* device, int* slice_count);
ErrorCodes_t device_get_slice(CredoDevice_t* device, int slice_index, CredoSlice_t** slice);
```
The devices job is simple in that it is meant to only store the slices that are available to it
## Slice
The acutual MCU's that configure lanes to make ports
### Management
```c
ErrorCodes_t slice_init(CredoSlice_t* slice, const CredoSliceConfig_t* config);
```
From a device you are able to get a device. For a device you can go through the process of initialization. This includes
- Loading Firmware
- Configuring lanes to a default state
- Setting PLL
- Performing necessary resets
- Providing driver information to communicate to it (provided in config)
The user can also opt out by using no_init flag to just having slice_init configure driver information.
### Information
Basic information about the slice including information that the user stores for their own needs.
```c
void* slice_get_userdata(const CredoSlice_t* slice);
void slice_set_userdata(CredoSlice_t* slice, void* userdata);
```
### Operations
Extremely basic level operations that allows the lowest of level operation on slice
```c
ErrorCodes_t slice_read(CredoSlice_t* slice, unsigned address, unsigned* value);
ErrorCodes_t slice_write(CredoSlice_t* slice, unsigned address, unsigned value);
```
### Setups
```c
ErrorCodes_t slice_load_setup(CredoSlice_t *slice, const char* file_path);
ErrorCodes_t slice_save_setup(CredoSlice_t *slice, const char* file_path);
```
### Power State
```c
ErrorCodes_t slice_set_power_state(CredoSlice_t *slice, int top);
```
### Testpoints (debug)
```c
ErrorCodes_t slice_select_testpoint(CredoSlice_t *slice, const char* group, int num, const char* mode);
ErrorCodes_t slice_disable_testpoints(CredoSlice_t *slice);
```
### Resets
All of the resets that can be performed on the chip
```c
ErrorCodes_t slice_reset_lane_rx(CredoSlice_t* slice, int lane);
ErrorCodes_t slice_soft_reset(CredoSlice_t* slice);
ErrorCodes_t slice_reset_logic(CredoSlice_t* slice);
ErrorCodes_t slice_reset_lane_logic(CredoSlice_t* slice, int lane);
ErrorCodes_t slice_reset_mcu(CredoSlice_t* slice);
ErrorCodes_t slice_reset_muc_hold(CredoSlice_t* slice);
ErrorCodes_t slice_reset_reg(CredoSlice_t* slice);
ErrorCodes_t slice_reset_lane_reg(CredoSlice_t* slice, int lane);
// TODO Rajan: do we need these???
ErrorCodes_t slice_reset_lane_fast(CredoSlice_t* slice, int lane);
ErrorCodes_t slice_reset_lane_simple(CredoSlice_t* slice, int lane);
```
### Top PLL
Top pll information
```c
ErrorCodes_t slice_cal_top_pll(CredoSlice_t* slice, int lane);
ErrorCodes_t slice_init_top_pll(CredoSlice_t* slice);
ErrorCodes_t slice_get_top_pll_cap(CredoSlice_t* slice, unsigned* cap);
```
## Firmware
Commands that are related or rely on firmware existing
### Management
Handle loading and unloading firmware.
```c
ErrorCodes_t firmware_unload(CredoSlice_t* slice);
ErrorCodes_t firmware_download(CredoSlice_t* slice, const char* image_file, int force);
ErrorCodes_t firmware_halt(CredoSlice_t* slice);
ErrorCodes_t firmware_continue(CredoSlice_t* slice);
ErrorCodes_t firmware_is_running(CredoSlice_t* slice, int* is_running);
ErrorCodes_t firmware_is_ready(CredoSlice_t* slice, int lane, int timeout_ms);
```
### Commands
The most basic operations that can be run on the firmware
```c
/* Raw command */
ErrorCodes_t firmware_cmd(CredoSlice_t* slice, unsigned cmd, unsigned param, unsigned* response,
unsigned* response_param);
ErrorCodes_t firmware_cmd_ex(CredoSlice_t* slice, unsigned cmd, unsigned param1, unsigned param2,
unsigned* response, unsigned* response_param1, unsigned* response_param2);
ErrorCodes_t firmware_debug_cmd(CredoSlice_t* slice, int lane, unsigned section, unsigned index,
unsigned* response_params);
/* Firmware register */
ErrorCodes_t firmware_reg_rd(CredoSlice_t* slice, unsigned addr, unsigned* value);
ErrorCodes_t firmware_reg_wr(CredoSlice_t* slice, unsigned addr, unsigned value);
ErrorCodes_t firmware_reg_rd_ex(CredoSlice_t* slice, unsigned addr, unsigned section, unsigned* value);
ErrorCodes_t firmware_reg_wr_ex(CredoSlice_t* slice, unsigned addr, unsigned section, unsigned value);
```
### Information
General information about the firmware
```c
ErrorCodes_t firmware_magic(CredoSlice_t* slice, unsigned* magic);
ErrorCodes_t firmware_ver(CredoSlice_t* slice, unsigned* version);
ErrorCodes_t firmware_hash(CredoSlice_t* slice, unsigned* hash);
ErrorCodes_t firmware_crc(CredoSlice_t* slice, unsigned* crc);
ErrorCodes_t firmware_date(CredoSlice_t* slice, unsigned* date);
```
### Operations
Information from the firmware
```c
ErrorCodes_t firmware_reset_counter(CredoSlice_t* slice, int lane);
```
### Port Operations
Firmware operations on a port that allow configuring and teardown. Most of the logic is stored in the port_config
```c
ErrorCodes_t firmware_create_port(CredoSlice_t* slice, const CredoPortConfig_t* port_config, int force);
ErrorCodes_t firmware_destroy_port(CredoSlice_t* slice, uint32_t portId);
ErrorCodes_t firmware_query_port(CredoSlice_t* slice, uint32_t portId, CredoPortConfig_t* port_config);
ErrorCodes_t firmware_clear_all_port(CredoSlice_t* slice);
```
### Lane Operations
```c
ErrorCodes_t firmware_destroy_lane(CredoSlice_t* slice, int lane);
```
### Serdes Operations
```c
ErrorCodes_t firmware_phy_ready(CredoSlice_t* slice, unsigned* rdy);
ErrorCodes_t firmware_opt_vref(CredoSlice_t* slice, int lane);
ErrorCodes_t firmware_get_isi(CredoSlice_t* slice, int lane, int isi[]);
```
## Display
### Info
These are logging commands that provide information about the state of the slice, port, lane, firmware. This typically
comes in the form of tables. Some examples of commands will be rx_monitor, serdes_param, port_info. The goal is to allow
as much flexibility per Chip type in what functions they would like to expose.
```c
ErrorCodes_t display_slice_info(CredoSlice_t* slice, const char* command);
ErrorCodes_t display_port_info(CredoSlice_t* slice, const char* command, uint32_t port_id);
ErrorCodes_t display_lane_info(CredoSlice_t* slice, const char* command, int lane);
ErrorCodes_t display_firmware_info(CredoSlice_t* slice, const char* command);
```
### Debug
Very similar to info functions except that they also allow up to two int args. These are therefore a more powerful
version of the info commands that I wanted for more internal use / debugging without documenting for customers.
```c
ErrorCodes_t display_slice_debug(CredoSlice_t* slice, const char* command, int param1, int param2);
ErrorCodes_t display_port_debug(CredoSlice_t* slice, const char* command, uint32_t port_id, int param1, int param2);
ErrorCodes_t display_lane_debug(CredoSlice_t* slice, const char* command, int lane, int param1, int param2);
ErrorCodes_t display_firmware_debug(CredoSlice_t* slice, const char* command, int param1, int param2);
```
## SerDes
These are all low-level configuration operations
### Power
```c
ErrorCodes_t set_tx_power_state(CredoSlice_t *slice, int lane, int state);
ErrorCodes_t set_rx_power_state(CredoSlice_t *slice, int lane, int state);
```
### Mode
DISABLED, OFF, NRZ, PAM4, AN information
```c
ErrorCodes_t get_lane_mode(CredoSlice_t*slice, int lane, CredoLaneMode_t* mode);
ErrorCodes_t set_lane_mode(CredoSlice_t* slice, int lane, CredoLaneMode_t mode);
```
### Capability
Information about what the capabilities of the slice are for things such as tap count. This information is needed for
configuring these tap based serdes parameters
```c
// FIXME: put near the code that will actually reference this.
ErrorCodes_t get_rx_ffe_range(CredoSlice_t* slice, int lane, int* length);
ErrorCodes_t get_rx_ffe_sums_range(CredoSlice_t* slice, int lane, int* length);
ErrorCodes_t get_tx_ffe_range(CredoSlice_t* slice, int lane, int* length, int* extended_length);
ErrorCodes_t get_rx_dfe_range(CredoSlice_t* slice, int lane, int* length);
ErrorCodes_t get_rx_isi_range(CredoSlice_t* slice, int lane, int* length);
ErrorCodes_t get_rx_ffe_pu_stages(CredoSlice_t* slice, int lane, int* length);
```
### Polarity
```c
ErrorCodes_t set_rx_polarity(CredoSlice_t* slice, int lane, int rx_pol);
ErrorCodes_t set_tx_polarity(CredoSlice_t* slice, int lane, int tx_pol);
ErrorCodes_t get_rx_polarity(CredoSlice_t*slice, int lane, int* rx_pol);
ErrorCodes_t get_tx_polarity(CredoSlice_t*slice, int lane, int* tx_pol);
```
### Input Mode
```c
ErrorCodes_t set_rx_input_mode(CredoSlice_t* slice, int lane, CredoLaneRxInputMode_t
input_mode);
ErrorCodes_t get_rx_input_mode(CredoSlice_t* slice, int lane, CredoLaneRxInputMode_t* input_mode);
```
### Graycoding & Precoding
```c
ErrorCodes_t set_tx_gray_code(CredoSlice_t* slice, int lane, int tx_gc);
ErrorCodes_t set_rx_gray_code(CredoSlice_t* slice, int lane, int rx_gc);
ErrorCodes_t get_tx_gray_code(CredoSlice_t* slice, int lane, int* tx_gc);
ErrorCodes_t get_rx_gray_code(CredoSlice_t* slice, int lane, int* rx_gc);
ErrorCodes_t set_tx_precoder(CredoSlice_t* slice, int lane, int tx_pc);
ErrorCodes_t set_rx_precoder(CredoSlice_t* slice, int lane, int rx_pc);
ErrorCodes_t get_tx_precoder(CredoSlice_t*slice, int lane, int* tx_pc);
ErrorCodes_t get_rx_precoder(CredoSlice_t*slice, int lane, int* rx_pc);
```
### Bit Swapping
```c
ErrorCodes_t get_tx_msb(CredoSlice_t*slice, int lane, int* tx_msb);
ErrorCodes_t set_tx_msb(CredoSlice_t* slice, int lane, int tx_msb);
ErrorCodes_t get_rx_msb(CredoSlice_t*slice, int lane, int* rx_msb);
ErrorCodes_t set_rx_msb(CredoSlice_t* slice, int lane, int rx_msb);
```
### Lane PLL
```c
ErrorCodes_t get_tx_pll(CredoSlice_t*slice, int lane, int* tx_pll);
ErrorCodes_t set_tx_pll(CredoSlice_t* slice, int lane, int tx_pll);
ErrorCodes_t get_rx_pll(CredoSlice_t*slice, int lane, int* rx_pll);
ErrorCodes_t set_rx_pll(CredoSlice_t* slice, int lane, int rx_pll);
ErrorCodes_t get_tx_cap(CredoSlice_t*slice, int lane, int* tx_cap);
ErrorCodes_t set_tx_cap(CredoSlice_t* slice, int lane, int tx_cap);
ErrorCodes_t get_rx_cap(CredoSlice_t*slice, int lane, int* rx_cap);
ErrorCodes_t set_rx_cap(CredoSlice_t* slice, int lane, int rx_cap);
ErrorCodes_t set_tx_pll_frac(CredoSlice_t*slice, int lane, int pll_n, int smen, int sdm_order, int mmdiv);
ErrorCodes_t get_tx_pll_frac(CredoSlice_t*slice, int lane, int* pll_n, int* smen, int* sdm_order, int* mmdiv);
ErrorCodes_t set_rx_pll_frac(CredoSlice_t*slice, int lane, int pll_n, int smen, int, sdm_order, int mmdiv);
ErrorCodes_t get_rx_pll_frac(CredoSlice_t*slice, int lane, int* pll_n, int* smen, int* sdm_order, int* mmdiv);
```
### Rx Details
```c
ErrorCodes_t get_rx_ppm(CredoSlice_t*slice, int lane, int* ppm);
ErrorCodes_t get_rx_skef(CredoSlice_t*slice, int lane, int* enable, int* value);
ErrorCodes_t set_rx_skef(CredoSlice_t* slice, int lane, int enable, int value);
ErrorCodes_t get_rx_dac(CredoSlice_t*slice, int lane, int* rx_dac);
ErrorCodes_t set_rx_dac(CredoSlice_t* slice, int lane, int rx_dac);
ErrorCodes_t get_rx_f1over3(CredoSlice_t* slice, int lane, int* value);
ErrorCodes_t set_rx_f1over3(CredoSlice_t* slice, int lane, int value);
ErrorCodes_t get_rx_agcgain(CredoSlice_t* slice, int lane, unsigned* agcgain);
ErrorCodes_t set_rx_agcgain(CredoSlice_t* slice, int lane, int value);
ErrorCodes_t get_rx_ctle(CredoSlice_t* slice, int lane, unsigned* value);
ErrorCodes_t set_rx_ctle(CredoSlice_t* slice, int lane, int value);
ErrorCodes_t get_rx_delta_phase(CredoSlice_t*slice, int lane, int* value);
ErrorCodes_t set_rx_delta_phase(CredoSlice_t* slice, int lane, int value);
ErrorCodes_t get_rx_edge(CredoSlice_t* slice, int lane, unsigned* value);
ErrorCodes_t set_rx_edge(CredoSlice_t* slice, int lane, unsigned value);
ErrorCodes_t get_rx_eye(CredoSlice_t* slice, int lane, int eyes[3]); // may only use 1
ErrorCodes_t get_rx_vref(CredoSlice_t* slice, int lane, int* value);
ErrorCodes_t set_rx_vref(CredoSlice_t* slice, int lane, int* value);
ErrorCodes_t get_rx_cdfl_eye(CredoSlice_t* slice, int lane, int* value);
ErrorCodes_t get_rx_cdfl_isi(CredoSlice_t* slice, int lane, int* value);
ErrorCodes_t get_rx_kp(CredoSlice_t *slice, int lane, int* kp);
ErrorCodes_t set_rx_kp(CredoSlice_t *slice, int lane, int kp);
ErrorCodes_t get_rx_kf(CredoSlice_t *slice, int lane, int* kf);
ErrorCodes_t set_rx_kf(CredoSlice_t *slice, int lane, int kf);
ErrorCodes_t get_rx_dfe(CredoSlice_t* slice, int lane, double dfe_taps[]); // may only use 1
```
### Status
```c
ErrorCodes_t lane_ready_status(CredoSlice_t*slice, int lane, int* status);
ErrorCodes_t signal_detect(CredoSlice_t* slice, int lane, int* sd);
```
### FFE
```c
// FIXME: what are the options for tx and rx
ErrorCodes_t get_tx_ffe_range(CredoSlice_t* slice, int lane, int* length, int* extended_length);
ErrorCodes_t get_rx_ffe_range(CredoSlice_t* slice, int lane, int* length);
ErrorCodes_t get_tx_ffe_taps(CredoSlice_t* slice, int lane, int taps[]);
ErrorCodes_t set_tx_ffe_taps(CredoSlice_t* slice, int lane, const int taps[]);
ErrorCodes_t get_tx_ffe_taps_scale(CredoSlice_t* slice, int lane, const unsigned taps_scale[]);
ErrorCodes_t set_tx_ffe_taps_scale(CredoSlice_t* slice, int lane, const unsigned taps_scale[]);
ErrorCodes_t get_tx_taps_extended(CredoSlice_t* slice, int lane, int taps_extended[]);
ErrorCodes_t set_tx_taps_extended(CredoSlice_t* slice, int lane, const int taps_extended[]);
ErrorCodes_t get_tx_ffe_tap_sums(CredoSlice_t* slice, int lane, int tap_sums[]);
ErrorCodes_t set_tx_ffe_tap_sums(CredoSlice_t* slice, int lane, const int tap_sums[]);
ErrorCodes_t get_rx_ffe_taps(CredoSlice_t* slice, int lane, int taps[]);
ErrorCodes_t set_rx_ffe_taps(CredoSlice_t* slice, int lane, const int taps[]);
ErrorCodes_t check_tx_ffe_taps(CredoSlice_t* slice, int lane);
```
### Rx Attenuation
```c
ErrorCodes_t set_rx_atten_en3db(CredoSlice_t *slice, int lane, int value);
ErrorCodes_t get_rx_atten_en3db(CredoSlice_t *slice, int lane, int* value);
ErrorCodes_t set_rx_atten_input(CredoSlice_t *slice, int lane, int value);
ErrorCodes_t get_rx_atten_input(CredoSlice_t *slice, int lane, int* value);
ErrorCodes_t set_rx_atten_agc(CredoSlice_t *slice, int lane, int value);
ErrorCodes_t get_rx_atten_agc(CredoSlice_t *slice, int lane, int* value);
ErrorCodes_t set_rx_atten2(CredoSlice_t *slice, int lane, int atten);
ErrorCodes_t get_rx_atten2(CredoSlice_t *slice, int lane, int* atten);
```
### Rx Debugging
```c
ErrorCodes_t set_rx_bp1(CredoSlice_t* slice, int lane, int enable, int state);
ErrorCodes_t get_rx_bp1(CredoSlice_t* slice, int lane, int* enable, int* state, int* reached);
ErrorCodes_t set_rx_bp2(CredoSlice_t* slice, int lane, int enable, int state);
ErrorCodes_t get_rx_bp2(CredoSlice_t* slice, int lane, int* enable, int* state, int* reached);
ErrorCodes_t get_rx_state(CredoSlice_t* slice, int lane, int* enable, int* state);
ErrorCodes_t continue_rx_sm(CredoSlice_t* slice, int lane);
ErrorCodes_t set_rx_counter_target(CredoSlice_t* slice, int lane, int target);
ErrorCodes_t get_rx_counter_target(CredoSlice_t* slice, int lane, int* target);
ErrorCodes_t set_rx_ffe_pu(CredoSlice_t* slice, int stages[]);
ErrorCodes_t get_rx_ffe_pu(CredoSlice_t* slice, int stages[]);
ErrorCodes_t set_rx_updown_mode(CredoSlice_t *slice, int lane, int t2, int t3, int t4, int flip);
ErrorCodes_t get_rx_updown_mode(CredoSlice_t *slice, int lane, int* t2, int* t3, int* t4, int* flip);
```
### PRBS
```c
ErrorCodes_t get_tx_prbs(CredoSlice_t*slice, int lane, int* enable, CredoLanePrbsPattern_t* mode);
ErrorCodes_t set_tx_prbs_nrz(CredoSlice_t* slice, int lane, int enable, CredoLanePrbsPattern_t mode);
ErrorCodes_t set_tx_prbs_pam4(CredoSlice_t* slice, int lane, int enable, CredoLanePrbsPattern_t mode);
ErrorCodes_t get_rx_prbs(CredoSlice_t*slice, int lane, int* enable, CredoLanePrbsPattern_t* mode);
ErrorCodes_t set_tx_prbs(CredoSlice_t* slice, int lane, int enable, CredoLanePrbsPattern_t mode);
ErrorCodes_t set_rx_prbs_nrz(CredoSlice_t* slice, int lane, int enable, CredoLanePrbsPattern_t mode);
ErrorCodes_t set_rx_prbs_pam4(CredoSlice_t* slice, int lane, int enable, CredoLanePrbsPattern_t mode);
ErrorCodes_t set_rx_prbs(CredoSlice_t* slice, int lane, int enable, CredoLanePrbsPattern_t mode);
ErrorCodes_t get_rx_prbs_cnt(CredoSlice_t* slice, int lane, uint32_t* count);
ErrorCodes_t set_rx_prbs_checker_enable(CredoSlice_t* slice, int lane, int enable);
ErrorCodes_t get_rx_prbs_checker_enable(CredoSlice_t* slice, int lane, int *enable);
ErrorCodes_t get_rx_prbs_ber(CredoSlice_t* slice, int lane, int time_ms, double*ber);
ErrorCodes_t reset_rx_prbs(CredoSlice_t* slice, int lane);
ErrorCodes_t gen_rx_prbs_1error(CredoSlice_t* slice, int lane);
```
### TX Control
```c
ErrorCodes_t tx_disable(CredoSlice_t* slice, int lane);
ErrorCodes_t tx_no_disable(CredoSlice_t* slice, int lane);
ErrorCodes_t tx_status(CredoSlice_t*slice, int lane, CredoLaneTxState_t* status);
```
### TX Asym
```c
ErrorCodes_t set_tx_asym_enable(CredoSlice_t* slice, int lane, int enable);
ErrorCodes_t get_tx_asym_enable(CredoSlice_t* slice, int lane, int* enable);
ErrorCodes_t set_tx_asym_level(CredoSlice_t* slice, int lane, int level[4]);
ErrorCodes_t get_tx_asym_level(CredoSlice_t* slice, int lane, int level[4]);
```
### TX Test Pattern
```c
ErrorCodes_t set_tx_test_pattern(CredoSlice_t* slice, int lane, unsigned long pattern);
ErrorCodes_t get_tx_test_pattern(CredoSlice_t* slice, int lane, unsigned long* pattern);
ErrorCodes_t set_tx_test_mode(CredoSlice_t* slice, int mode);
ErrorCodes_t get_tx_test_mode(CredoSlice_t* slice, int* mode);
```
## FEC Analyzer
> :warning: Postponed to 0.3.0.
```c
// ignore for now
// ErrorCodes_t fec_read_hist(CredoSlice_t* slice, int lane, int block);
// ErrorCodes_t fec_read_post_fec_ber(CredoSlice_t* slice, int lane, int time_ms, int prbs_mode);
// ErrorCodes_t fec_read_post_fec_ber(CredoSlice_t* slice, int lane, int time_ms, int prbs_mode, int block);
```
## ANLT
> :warning: Postponed to 0.3.0.
## Typings
```c
/**************************************************************************/
/* SDK information output, debug, error */
#define LOG_ERROR 0
#define LOG_WARN 1
#define LOG_INFO 2
#define LOG_DEBUG 3
typedef enum {
SUCCESS = 0,
FAIL = -1,
PHY_FW_DOWNLOAD_FAIL = -3,
FW_TIMEOUT = -4,
NOT_READY = -5,
OUT_OF_MEMORY = -6,
HAL_LOAD_FAIL = -7,
HAL_NOT_FOUND = -8,
INVALID_ARGS = -9,
NOTIMPLEMENTED = -100,
} ErrorCodes_t;
// Driver API
typedef ErrorCodes_t (*CredoReadRegister_t)(void* slice_context, unsigned reg_addr, unsigned* val);
typedef ErrorCodes_t (*CredoWriteRegister_t)(void* slice_context, unsigned reg_addr, unsigned val);
/* Optional device access */
typedef ErrorCodes_t (*CredoReadRegisterBurst_t)(void* slice_context, unsigned first_addr, unsigned val[],
unsigned count);
typedef ErrorCodes_t (*CredoWriteRegisterBurst_t)(void* slice_context, unsigned first_addr, const unsigned val[],
unsigned count);
// Logging API
typedef void (*CredoLog_t)(void* slice_context, void* user_data, int level, void* str);
typedef struct CredoSdkConfig {
CredoLog_t log;
CredoReadRegister_t read_register;
CredoWriteRegister_t write_register;
int max_log_level;
} CredoSdkConfig_t;
#define MAX_LANE_PER_SLICE 128
typedef struct CredoSliceConfig {
uint8_t no_init; // allow for users to connect to slice without loading firmware
const char* firmware_filename;
uint32_t slice_id;
void* slice_context;
} CredoSliceConfig_t;
/**************************************************************************/
/* Context types. These are all opaque. */
typedef struct CredoSdk CredoSdk_t;
typedef struct CredoDevice CredoDevice_t;
typedef struct CredoSlice CredoSlice_t;
/**************************************************************************/
/* Port and operation modes */
typedef enum {
Retimer,
RetimerCross,
BitMux,
Gearbox,
Phy,
Loopback,
} CredoPortConnectionMode_t;
typedef enum {
SerDesMode, // issue w/ (exactly like bald_eagle mode w/o PCS?)
MacsecBypass, // serdes + pcs used (no macsec)
Macsec, // macsec all blocks used
} CredoPortMode_t;
typedef enum {
DC = 0,
AC,
} CredoLaneRxInputMode_t;
typedef enum {
DISABLED = -1,
OFF = 0,
NRZ = 1,
PAM4 = 2,
AN = 3,
} CredoLaneMode_t;
typedef enum {
PRBS9 = 0,
PRBS13 = 1,
PRBS15 = 2,
PRBS23 = 3,
PRBS31 = 4,
PRBS_UNKNOWN = 100,
} CredoLanePrbsPattern_t;
typedef enum {
Unknown,
LowPower,
Traffic,
Squelch,
PRBSPAM4,
PRBSNRZ,
ForceDisable,
ForcePRBSPAM4,
ForcePRBSNRZ,
ForceTraffic,
} CredoLaneTxState_t;
typedef struct {
uint32_t port_id;
uint32_t flags;
CredoPortConnectionMode_t connection_mode;
CredoPortMode_t port_mode;
uint32_t speed;
uint32_t line_start_lane;
uint32_t host_start_lane;
uint32_t line_no_of_lanes;
uint32_t host_no_of_lanes;
} CredoPortConfig_t;
```