25 #ifndef LIBSWITCHTEC_SWITCHTEC_H 26 #define LIBSWITCHTEC_SWITCHTEC_H 36 #include "registers.h" 49 #define SWITCHTEC_MAX_PARTS 48 50 #define SWITCHTEC_MAX_PORTS 48 51 #define SWITCHTEC_MAX_STACKS 8 52 #define SWITCHTEC_MAX_EVENT_COUNTERS 64 53 #define SWITCHTEC_UNBOUND_PORT 255 54 #define SWITCHTEC_PFF_PORT_VEP 100 56 #define SWITCHTEC_FLASH_BOOT_PART_START 0xa8000000 57 #define SWITCHTEC_FLASH_MAP0_PART_START 0xa8020000 58 #define SWITCHTEC_FLASH_MAP1_PART_START 0xa8040000 59 #define SWITCHTEC_FLASH_PART_LEN 0x10000 61 #define SWITCHTEC_CMD_MASK 0xffff 62 #define SWITCHTEC_PAX_ID_SHIFT 18 63 #define SWITCHTEC_PAX_ID_MASK 0x1f 64 #define SWITCHTEC_PAX_ID_LOCAL SWITCHTEC_PAX_ID_MASK 67 #define __gas __attribute__((noderef, address_space(1))) 72 #define _PURE __attribute__ ((pure)) 78 #define SWITCHTEC_MAP_FAILED ((gasptr_t) -1) 86 SWITCHTEC_GEN_UNKNOWN,
93 SWITCHTEC_REVA = 0x0f,
94 SWITCHTEC_REVB = 0x00,
95 SWITCHTEC_REVC = 0x01,
96 SWITCHTEC_REV_UNKNOWN = 0xff
103 SWITCHTEC_BOOT_PHASE_BL1 = 1,
104 SWITCHTEC_BOOT_PHASE_BL2,
105 SWITCHTEC_BOOT_PHASE_FW,
106 SWITCHTEC_BOOT_PHASE_UNKNOWN
118 SWITCHTEC_VAR_UNKNOWN,
179 SWITCHTEC_BW_TYPE_RAW = 0x0,
180 SWITCHTEC_BW_TYPE_PAYLOAD = 0x1,
190 SWITCHTEC_LOG_MEMLOG,
192 SWITCHTEC_LOG_SYS_STACK,
193 SWITCHTEC_LOG_THRD_STACK,
198 enum switchtec_fw_type {
199 SWITCHTEC_FW_TYPE_UNKNOWN = 0,
200 SWITCHTEC_FW_TYPE_BOOT,
201 SWITCHTEC_FW_TYPE_MAP,
202 SWITCHTEC_FW_TYPE_IMG,
203 SWITCHTEC_FW_TYPE_CFG,
204 SWITCHTEC_FW_TYPE_NVLOG,
205 SWITCHTEC_FW_TYPE_SEEPROM,
206 SWITCHTEC_FW_TYPE_KEY,
207 SWITCHTEC_FW_TYPE_BL2,
216 enum switchtec_fw_type type;
233 unsigned long secure_version;
239 } boot, map, img, cfg, nvlog, seeprom, key, bl2;
256 unsigned part[SWITCHTEC_MAX_PARTS];
259 unsigned pff[SWITCHTEC_MAX_PFF_CSR];
266 SWITCHTEC_EVT_INVALID = -1,
267 SWITCHTEC_GLOBAL_EVT_STACK_ERROR,
268 SWITCHTEC_GLOBAL_EVT_PPU_ERROR,
269 SWITCHTEC_GLOBAL_EVT_ISP_ERROR,
270 SWITCHTEC_GLOBAL_EVT_SYS_RESET,
271 SWITCHTEC_GLOBAL_EVT_FW_EXC,
272 SWITCHTEC_GLOBAL_EVT_FW_NMI,
273 SWITCHTEC_GLOBAL_EVT_FW_NON_FATAL,
274 SWITCHTEC_GLOBAL_EVT_FW_FATAL,
275 SWITCHTEC_GLOBAL_EVT_TWI_MRPC_COMP,
276 SWITCHTEC_GLOBAL_EVT_TWI_MRPC_COMP_ASYNC,
277 SWITCHTEC_GLOBAL_EVT_CLI_MRPC_COMP,
278 SWITCHTEC_GLOBAL_EVT_CLI_MRPC_COMP_ASYNC,
279 SWITCHTEC_GLOBAL_EVT_GPIO_INT,
280 SWITCHTEC_GLOBAL_EVT_GFMS,
281 SWITCHTEC_PART_EVT_PART_RESET,
282 SWITCHTEC_PART_EVT_MRPC_COMP,
283 SWITCHTEC_PART_EVT_MRPC_COMP_ASYNC,
284 SWITCHTEC_PART_EVT_DYN_PART_BIND_COMP,
285 SWITCHTEC_PFF_EVT_AER_IN_P2P,
286 SWITCHTEC_PFF_EVT_AER_IN_VEP,
287 SWITCHTEC_PFF_EVT_DPC,
288 SWITCHTEC_PFF_EVT_CTS,
289 SWITCHTEC_PFF_EVT_UEC,
290 SWITCHTEC_PFF_EVT_HOTPLUG,
291 SWITCHTEC_PFF_EVT_IER,
292 SWITCHTEC_PFF_EVT_THRESH,
293 SWITCHTEC_PFF_EVT_POWER_MGMT,
294 SWITCHTEC_PFF_EVT_TLP_THROTTLING,
295 SWITCHTEC_PFF_EVT_FORCE_SPEED,
296 SWITCHTEC_PFF_EVT_CREDIT_TIMEOUT,
297 SWITCHTEC_PFF_EVT_LINK_STATE,
298 SWITCHTEC_MAX_EVENTS,
307 int device,
int func);
309 struct switchtec_dev *switchtec_open_i2c_by_adapter(
int adapter,
int i2c_addr);
317 const void *payload,
size_t payload_len,
void *resp,
323 int *partition,
int *port);
329 struct switchtec_event_summary *check,
330 struct switchtec_event_summary *res);
333 int index,
int flags,
346 int switchtec_set_pax_id(
struct switchtec_dev *dev,
int pax_id);
347 int switchtec_echo(
struct switchtec_dev *dev, uint32_t input, uint32_t *output);
353 enum switchtec_boot_phase *phase,
354 enum switchtec_gen *gen,
453 static inline const char *
457 case SWITCHTEC_GEN3:
return "GEN3";
458 case SWITCHTEC_GEN4:
return "GEN4";
459 default:
return "UNKNOWN";
484 static inline const char *switchtec_ltssm_str(
int ltssm,
int show_minor)
490 case 0x0000:
return "Detect (INACTIVE)";
491 case 0x0100:
return "Detect (QUIET)";
492 case 0x0200:
return "Detect (SPD_CHD0)";
493 case 0x0300:
return "Detect (SPD_CHD1)";
494 case 0x0400:
return "Detect (ACTIVE0)";
495 case 0x0500:
return "Detect (ACTIVE1)";
496 case 0x0600:
return "Detect (P1_TO_P0)";
497 case 0x0700:
return "Detect (P0_TO_P1_0)";
498 case 0x0800:
return "Detect (P0_TO_P1_1)";
499 case 0x0900:
return "Detect (P0_TO_P1_2)";
500 case 0xFF00:
return "Detect";
501 case 0x0001:
return "Polling (INACTIVE)";
502 case 0x0101:
return "Polling (ACTIVE_ENTRY)";
503 case 0x0201:
return "Polling (ACTIVE)";
504 case 0x0301:
return "Polling (CFG)";
505 case 0x0401:
return "Polling (COMP)";
506 case 0x0501:
return "Polling (COMP_ENTRY)";
507 case 0x0601:
return "Polling (COMP_EIOS)";
508 case 0x0701:
return "Polling (COMP_EIOS_ACK)";
509 case 0x0801:
return "Polling (COMP_IDLE)";
510 case 0xFF01:
return "Polling";
511 case 0x0002:
return "Config (INACTIVE)";
512 case 0x0102:
return "Config (US_LW_START)";
513 case 0x0202:
return "Config (US_LW_ACCEPT)";
514 case 0x0302:
return "Config (US_LN_WAIT)";
515 case 0x0402:
return "Config (US_LN_ACCEPT)";
516 case 0x0502:
return "Config (DS_LW_START)";
517 case 0x0602:
return "Config (DS_LW_ACCEPT)";
518 case 0x0702:
return "Config (DS_LN_WAIT)";
519 case 0x0802:
return "Config (DS_LN_ACCEPT)";
520 case 0x0902:
return "Config (COMPLETE)";
521 case 0x0A02:
return "Config (IDLE)";
522 case 0xFF02:
return "Config";
523 case 0x0003:
return "L0 (INACTIVE)";
524 case 0x0103:
return "L0 (L0)";
525 case 0x0203:
return "L0 (TX_EL_IDLE)";
526 case 0x0303:
return "L0 (TX_IDLE_MIN)";
527 case 0xFF03:
return "L0";
528 case 0x0004:
return "Recovery (INACTIVE)";
529 case 0x0104:
return "Recovery (RCVR_LOCK)";
530 case 0x0204:
return "Recovery (RCVR_CFG)";
531 case 0x0304:
return "Recovery (IDLE)";
532 case 0x0404:
return "Recovery (SPEED0)";
533 case 0x0504:
return "Recovery (SPEED1)";
534 case 0x0604:
return "Recovery (SPEED2)";
535 case 0x0704:
return "Recovery (SPEED3)";
536 case 0x0804:
return "Recovery (EQ_PH0)";
537 case 0x0904:
return "Recovery (EQ_PH1)";
538 case 0x0A04:
return "Recovery (EQ_PH2)";
539 case 0x0B04:
return "Recovery (EQ_PH3)";
540 case 0xFF04:
return "Recovery";
541 case 0x0005:
return "Disable (INACTIVE)";
542 case 0x0105:
return "Disable (DISABLE0)";
543 case 0x0205:
return "Disable (DISABLE1)";
544 case 0x0305:
return "Disable (DISABLE2)";
545 case 0x0405:
return "Disable (DISABLE3)";
546 case 0xFF05:
return "Disable";
547 case 0x0006:
return "Loop Back (INACTIVE)";
548 case 0x0106:
return "Loop Back (ENTRY)";
549 case 0x0206:
return "Loop Back (ENTRY_EXIT)";
550 case 0x0306:
return "Loop Back (EIOS)";
551 case 0x0406:
return "Loop Back (EIOS_ACK)";
552 case 0x0506:
return "Loop Back (IDLE)";
553 case 0x0606:
return "Loop Back (ACTIVE)";
554 case 0x0706:
return "Loop Back (EXIT0)";
555 case 0x0806:
return "Loop Back (EXIT1)";
556 case 0xFF06:
return "Loop Back";
557 case 0x0007:
return "Hot Reset (INACTIVE)";
558 case 0x0107:
return "Hot Reset (HOT_RESET)";
559 case 0x0207:
return "Hot Reset (MASTER_UP)";
560 case 0x0307:
return "Hot Reset (MASTER_DOWN)";
561 case 0xFF07:
return "Hot Reset";
562 case 0x0008:
return "TxL0s (INACTIVE)";
563 case 0x0108:
return "TxL0s (IDLE)";
564 case 0x0208:
return "TxL0s (T0_L0)";
565 case 0x0308:
return "TxL0s (FTS0)";
566 case 0x0408:
return "TxL0s (FTS1)";
567 case 0xFF08:
return "TxL0s";
568 case 0x0009:
return "L1 (INACTIVE)";
569 case 0x0109:
return "L1 (IDLE)";
570 case 0x0209:
return "L1 (SUBSTATE)";
571 case 0x0309:
return "L1 (SPD_CHG1)";
572 case 0x0409:
return "L1 (T0_L0)";
573 case 0xFF09:
return "L1";
574 case 0x000A:
return "L2 (INACTIVE)";
575 case 0x010A:
return "L2 (IDLE)";
576 case 0x020A:
return "L2 (TX_WAKE0)";
577 case 0x030A:
return "L2 (TX_WAKE1)";
578 case 0x040A:
return "L2 (EXIT)";
579 case 0x050A:
return "L2 (SPEED)";
580 case 0xFF0A:
return "L2";
581 default:
return "UNKNOWN";
593 SWITCHTEC_EVT_FLAG_CLEAR = 1 << 0,
594 SWITCHTEC_EVT_FLAG_EN_POLL = 1 << 1,
595 SWITCHTEC_EVT_FLAG_EN_LOG = 1 << 2,
596 SWITCHTEC_EVT_FLAG_EN_CLI = 1 << 3,
597 SWITCHTEC_EVT_FLAG_EN_FATAL = 1 << 4,
598 SWITCHTEC_EVT_FLAG_DIS_POLL = 1 << 5,
599 SWITCHTEC_EVT_FLAG_DIS_LOG = 1 << 6,
600 SWITCHTEC_EVT_FLAG_DIS_CLI = 1 << 7,
601 SWITCHTEC_EVT_FLAG_DIS_FATAL = 1 << 8,
612 SWITCHTEC_EVT_IDX_LOCAL = -1,
613 SWITCHTEC_EVT_IDX_ALL = -2,
621 SWITCHTEC_EVT_GLOBAL,
640 struct switchtec_event_summary *res,
650 SWITCHTEC_DLSTAT_READY = 0,
651 SWITCHTEC_DLSTAT_INPROGRESS = 1,
652 SWITCHTEC_DLSTAT_HEADER_INCORRECT = 2,
653 SWITCHTEC_DLSTAT_OFFSET_INCORRECT = 3,
654 SWITCHTEC_DLSTAT_CRC_INCORRECT = 4,
655 SWITCHTEC_DLSTAT_LENGTH_INCORRECT = 5,
656 SWITCHTEC_DLSTAT_HARDWARE_ERR = 6,
657 SWITCHTEC_DLSTAT_COMPLETES = 7,
658 SWITCHTEC_DLSTAT_SUCCESS_FIRM_ACT = 8,
659 SWITCHTEC_DLSTAT_SUCCESS_DATA_ACT = 9,
660 SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT = 14,
662 SWITCHTEC_DLSTAT_NO_FILE = 0x7d009,
673 enum switchtec_fw_redundancy {
674 SWITCHTEC_FW_REDUNDANCY_SET = 1,
675 SWITCHTEC_FW_REDUNDANCY_CLEAR = 0,
679 int toggle_bl2,
int toggle_key,
680 int toggle_fw,
int toggle_cfg);
682 enum switchtec_fw_redundancy redund,
683 enum switchtec_fw_type type);
685 int dont_activate,
int force,
686 void (*progress_callback)(
int cur,
int tot));
688 int dont_activate,
int force,
689 void (*progress_callback)(
int cur,
int tot));
691 unsigned long addr,
size_t len,
692 void (*progress_callback)(
int cur,
int tot));
695 void (*progress_callback)(
int cur,
int tot));
697 size_t len,
void *buf);
710 int switchtec_bind_info(
struct switchtec_dev *dev,
713 int switchtec_bind(
struct switchtec_dev *dev,
int par_id,
714 int log_port,
int phy_port);
715 int switchtec_unbind(
struct switchtec_dev *dev,
int par_id,
int log_port);
800 unsigned cntr_id,
unsigned nr_cntrs,
803 unsigned cntr_id,
unsigned nr_cntrs,
unsigned *res,
806 unsigned cntr_id,
unsigned nr_cntrs,
808 unsigned *counts,
int clear);
834 int *phys_port_ids,
int clear,
843 #define SWITCHTEC_LAT_ALL_INGRESS 63 846 int *egress_port_ids,
int *ingress_port_ids);
848 int ingress_port_id,
int clear);
850 int clear,
int *egress_port_ids,
851 int *cur_ns,
int *max_ns);
853 int egress_port_ids,
int *cur_ns,
unsigned char cfg_lnk_width
Configured link width.
unsigned char neg_lnk_width
Negotiated link width.
char product_rev[8]
Product revision.
char * pci_dev
PCI BDF of the device on the port.
unsigned int acs_ctrl
ACS Setting of the Port.
static int switchtec_is_pfxl(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-L.
switchtec_evcntr_type_mask
Event counter type mask (may be or-d together)
void switchtec_status_free(struct switchtec_status *status, int ports)
Free a list of status structures allocated by switchtec_status()
Unsupported Request Error.
unsigned char upstream
1 if this is an upstream port
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.
unsigned char link_rate
Link rate/gen.
Rule Search Table Rule Hit.
_PURE int switchtec_device_id(struct switchtec_dev *dev)
Get the device id of the device.
const char * switchtec_evcntr_type_str(int *type_mask)
Get a string for the event indicated by lowest bit set in the type_mask.
size_t part_addr
Address of the partition.
uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d)
Get the total.
uint64_t comp
Completion TLP bytes.
Uncorrectable Internal Error.
uint64_t time_us
Time (in microseconds)
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.
static const float switchtec_gen_transfers[]
Number of GT/s capable for each PCI generation or link_rate.
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_port_to_pff(struct switchtec_dev *dev, int partition, int port, int *pff)
Convert a partition and port number to a port function index.
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_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_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.
Receive Correctable Error Message.
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.
static const char * switchtec_gen_str(struct switchtec_dev *dev)
Return the generation string of a Switchtec device.
unsigned char partition
Partition the port is in.
int switchtec_status(struct switchtec_dev *dev, struct switchtec_status **status)
Get the status of all the ports on a switchtec device.
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. ...
unsigned long image_crc
CRC checksum of the image.
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.
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.
switchtec_gen
The PCIe generations.
unsigned char stk_id
Port number within the stack.
switchtec_event_id
Enumeration of all possible events.
unsigned char first_act_lane
First active lane.
Information about a firmware image or partition.
switchtec_boot_phase
Device boot phase.
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.
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 ev...
Mask indicating all possible errors.
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.
char * pci_bdf_path
PCI BDF path of the port.
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_fw_img_write_hdr(int fd, struct switchtec_fw_image_info *info)
Write the header for a Switchtec firmware image file.
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.
unsigned long part_id
Image partition ID.
void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map)
Unmap the GAS region mapped with.
Structure used to setup an event counter.
switchtec_bw_type
The types of bandwidth.
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.
__gas struct switchtec_gas * gasptr_t
Shortform for a pointer to the GAS register space.
char product_id[32]
Product ID.
int switchtec_list(struct switchtec_device_info **devlist)
List all the switchtec devices in the system.
unsigned char phys_id
Physical port number.
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 plug...
int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms)
Block until any event counter has reached its threshold.
static int switchtec_is_pax(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX.
size_t image_len
Length of the image.
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.
uint64_t part_bitmap
Bitmap of partitions with active events.
int switchtec_evcntr_type_count(void)
Get the number of event counter types.
switchtec_log_type
Describe the type of logs too dump.
static int switchtec_is_pfx(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX.
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.
float switchtec_die_temp(struct switchtec_dev *dev)
Get the die temperature of the switchtec device.
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.
void switchtec_fw_perror(const char *s, int ret)
Print an error string to stdout.
char path[PATH_MAX]
Path to the device.
unsigned threshold
Threshold to count to before generating an interrupt.
char desc[256]
Device description, if available.
uint64_t nonposted
Non-Posted TLP bytes.
static const char * switchtec_fw_image_gen_str(struct switchtec_fw_image_info *inf)
Return the generation string of a Switchtec fw image.
static int switchtec_is_gen4(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 4 device.
_PURE int switchtec_partition(struct switchtec_dev *dev)
Get the partiton number of the device that was opened.
unsigned char stack
Stack number.
int switchtec_event_wait(struct switchtec_dev *dev, int timeout_ms)
Wait for any event to occur (typically just an interrupt)
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.
const char * lane_reversal_str
Lane reversal as a string.
const char * switchtec_strerror(void)
Return a message coresponding to the last error.
int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output)
Perform an MRPC echo command.
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.
enum switchtec_gen gen
Image generation.
switchtec_fw_ro
Flag which indicates if a partition is read-only or not.
static int switchtec_is_pfxi(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-I.
void switchtec_fw_part_summary_free(struct switchtec_fw_part_summary *summary)
Free a firmware part summary data structure.
Mask indicating all event types.
unsigned char lane_reversal
Lane reversal.
size_t part_body_offset
Partition image body offset.
int switchtec_fw_is_boot_ro(struct switchtec_dev *dev)
Check if the boot partition is marked as read-only.
int switchtec_fw_read(struct switchtec_dev *dev, unsigned long addr, size_t len, void *buf)
Read a Switchtec device's flash data.
char * class_devices
Comma seperated list of classes.
switchtec_variant
The variant types of Switchtec device.
const char * ltssm_str
Link state as a string.
uint64_t global
Bitmap of global events.
int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info)
Retrieve information about a firmware image file.
Header Log Overflow Error.
Mask indicating all TLP types.
int switchtec_fw_setup_redundancy(struct switchtec_dev *dev, enum switchtec_fw_redundancy redund, enum switchtec_fw_type type)
Set or clear the redundancy flag of a partition type.
switchtec_fw_dlstatus
Firmware update status.
const char * switchtec_fw_image_type(const struct switchtec_fw_image_info *info)
Return a string describing the type of a firmware image.
int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf, size_t buflen)
Get the firmware version as a user readable string.
char pci_dev[256]
PCI BDF string.
static int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX or PSX.
struct switchtec_dev * switchtec_open_uart(int fd)
Open a switchtec device behind a uart device.
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.
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.
static int switchtec_is_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX(L/I).
struct switchtec_dev * switchtec_open_by_path(const char *path)
Open a switchtec device by path.
char fw_version[32]
Firmware version.
size_t part_len
Length of the partition.
switchtec_event_special
Special event indexes numbers.
static int switchtec_is_gen3(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 3 device.
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.
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.
char name[256]
Device name, eg. switchtec0.
switchtec_event_flags
Event control flags.
switchtec_event_type
There are three event types indicated by this enumeration: global, partition and port function...
void switchtec_perror(const char *str)
Print an error string to stdout.
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.
Receive FATAL Error Message.
switchtec_rev
Device hardware revision.
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.
struct switchtec_dev * switchtec_open(const char *device)
Open a Switchtec device by string.
Null-terminated list of all event counter types with a name and help text.
char * pci_bdf
PCI BDF of the port.
_PURE const char * switchtec_name(struct switchtec_dev *dev)
Get the string that was used to open the deviec.
int switchtec_log_to_file(struct switchtec_dev *dev, enum switchtec_log_type type, int fd)
Dump the Switchtec log data to a file.
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_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_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.
unsigned char log_id
Logical port number.
Represents a Switchtec device in the switchtec_list() function.
struct switchtec_dev * switchtec_open_i2c(const char *path, int i2c_addr)
Open a switchtec device behind an I2C device.
Data Link Protocol Error.
struct switchtec_dev * switchtec_open_by_index(int index)
Open a switchtec device by index.
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_summary(struct switchtec_dev *dev, struct switchtec_event_summary *sum)
Retrieve a summary of all the events that have occurred in the switch.
struct switchtec_dev * switchtec_open_by_pci_addr(int domain, int bus, int device, int func)
Open a switchtec device by PCI address (BDF)
int switchtec_lat_setup(struct switchtec_dev *dev, int egress_port_id, int ingress_port_id, int clear)
Setup a latency counter.
Bandwidth counter result struct.
unsigned local_part
Bitmap of events in the local partition.
uint64_t posted
Posted TLP bytes.
static const char * switchtec_variant_str(struct switchtec_dev *dev)
Return the variant string of a Switchtec device.
unsigned char link_up
1 if the link is up
int switchtec_hard_reset(struct switchtec_dev *dev)
Perform an MRPC hard reset command.
Receive Non-FATAL Error Message.
static int switchtec_is_psx(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX.
void switchtec_close(struct switchtec_dev *dev)
Close a Switchtec device handle.
static const float switchtec_gen_datarate[]
Number of GB/s capable for each PCI generation or link_rate.
uint16_t ltssm
Link state.