25#ifndef LIBSWITCHTEC_SWITCHTEC_H
26#define LIBSWITCHTEC_SWITCHTEC_H
51#define SWITCHTEC_MAX_PARTS 48
52#define SWITCHTEC_MAX_PORTS 60
53#define SWITCHTEC_MAX_PORTS_GEN6 20
54#define SWITCHTEC_MAX_LANES 100
55#define SWITCHTEC_MAX_LANES_GEN6 144
56#define SWITCHTEC_MAX_STACKS 8
57#define SWITCHTEC_MAX_STACKS_GEN6 4
58#define SWITCHTEC_PORTS_PER_STACK 8
59#define SWITCHTEC_MAX_EVENT_COUNTERS 64
60#define SWITCHTEC_UNBOUND_PORT 255
61#define SWITCHTEC_PFF_PORT_VEP 100
63#define SWITCHTEC_FLASH_BOOT_PART_START 0xa8000000
64#define SWITCHTEC_FLASH_MAP0_PART_START 0xa8020000
65#define SWITCHTEC_FLASH_MAP1_PART_START 0xa8040000
66#define SWITCHTEC_FLASH_PART_LEN 0x10000
68#define SWITCHTEC_CMD_MASK 0xffff
69#define SWITCHTEC_PAX_ID_SHIFT 18
70#define SWITCHTEC_PAX_ID_MASK 0x1f
71#define SWITCHTEC_PAX_ID_LOCAL SWITCHTEC_PAX_ID_MASK
73#define SWITCHTEC_DIAG_MAX_TLP_DWORDS 132
75#define SWITCHTEC_MAX_GPIO_PIN_VALS 30
78#define __gas __attribute__((noderef, address_space(1)))
83#define _PURE __attribute__ ((pure))
89#define SWITCHTEC_MAP_FAILED ((gasptr_t) -1)
99 SWITCHTEC_GEN_UNKNOWN,
106 SWITCHTEC_REVA = 0x0f,
107 SWITCHTEC_REVA1 = 0x0e,
108 SWITCHTEC_REVB = 0x00,
109 SWITCHTEC_REVC = 0x01,
110 SWITCHTEC_REV_UNKNOWN = 0xff
117 SWITCHTEC_BOOT_PHASE_BL1 = 1,
118 SWITCHTEC_BOOT_PHASE_BL2,
119 SWITCHTEC_BOOT_PHASE_FW,
120 SWITCHTEC_BOOT_PHASE_UNKNOWN
127 SWITCHTEC_PART_TYPE_KEYMAN = 1,
128 SWITCHTEC_PART_TYPE_RC = 2,
129 SWITCHTEC_PART_TYPE_BL2 = 3,
130 SWITCHTEC_PART_TYPE_CFG = 4,
131 SWITCHTEC_PART_TYPE_FW = 5
146 SWITCHTEC_VAR_UNKNOWN,
208 SWITCHTEC_BW_TYPE_RAW = 0x0,
209 SWITCHTEC_BW_TYPE_PAYLOAD = 0x1,
220 SWITCHTEC_LOG_MEMLOG,
222 SWITCHTEC_LOG_SYS_STACK,
223 SWITCHTEC_LOG_THRD_STACK,
232 SWITCHTEC_LOG_PARSE_TYPE_APP,
233 SWITCHTEC_LOG_PARSE_TYPE_MAILBOX,
234 SWITCHTEC_LOG_PARSE_TYPE_FTDC
241 unsigned int log_fw_version;
242 unsigned int log_sdk_version;
243 unsigned int def_fw_version;
244 unsigned int def_sdk_version;
245 bool version_mismatch;
255 SWITCHTEC_LOG_DEF_TYPE_APP,
256 SWITCHTEC_LOG_DEF_TYPE_MAILBOX
259enum switchtec_fw_type {
260 SWITCHTEC_FW_TYPE_UNKNOWN = 0,
261 SWITCHTEC_FW_TYPE_BOOT,
262 SWITCHTEC_FW_TYPE_MAP,
263 SWITCHTEC_FW_TYPE_IMG,
264 SWITCHTEC_FW_TYPE_CFG,
265 SWITCHTEC_FW_TYPE_NVLOG,
266 SWITCHTEC_FW_TYPE_SEEPROM,
267 SWITCHTEC_FW_TYPE_KEY,
268 SWITCHTEC_FW_TYPE_BL2,
269 SWITCHTEC_FW_TYPE_RIOT,
324 unsigned long secure_version;
332 } boot, map, img, cfg, nvlog, seeprom, key, bl2, riot, token;
349 unsigned part[SWITCHTEC_MAX_PARTS];
352 unsigned pff[SWITCHTEC_MAX_PFF_CSR];
359 SWITCHTEC_EVT_INVALID = -1,
360 SWITCHTEC_GLOBAL_EVT_STACK_ERROR,
361 SWITCHTEC_GLOBAL_EVT_PPU_ERROR,
362 SWITCHTEC_GLOBAL_EVT_ISP_ERROR,
363 SWITCHTEC_GLOBAL_EVT_SYS_RESET,
364 SWITCHTEC_GLOBAL_EVT_FW_EXC,
365 SWITCHTEC_GLOBAL_EVT_FW_NMI,
366 SWITCHTEC_GLOBAL_EVT_FW_NON_FATAL,
367 SWITCHTEC_GLOBAL_EVT_FW_FATAL,
368 SWITCHTEC_GLOBAL_EVT_TWI_MRPC_COMP,
369 SWITCHTEC_GLOBAL_EVT_TWI_MRPC_COMP_ASYNC,
370 SWITCHTEC_GLOBAL_EVT_CLI_MRPC_COMP,
371 SWITCHTEC_GLOBAL_EVT_CLI_MRPC_COMP_ASYNC,
372 SWITCHTEC_GLOBAL_EVT_GPIO_INT,
373 SWITCHTEC_GLOBAL_EVT_GFMS,
374 SWITCHTEC_PART_EVT_PART_RESET,
375 SWITCHTEC_PART_EVT_MRPC_COMP,
376 SWITCHTEC_PART_EVT_MRPC_COMP_ASYNC,
377 SWITCHTEC_PART_EVT_DYN_PART_BIND_COMP,
378 SWITCHTEC_PFF_EVT_AER_IN_P2P,
379 SWITCHTEC_PFF_EVT_AER_IN_VEP,
380 SWITCHTEC_PFF_EVT_DPC,
381 SWITCHTEC_PFF_EVT_CTS,
382 SWITCHTEC_PFF_EVT_UEC,
383 SWITCHTEC_PFF_EVT_HOTPLUG,
384 SWITCHTEC_PFF_EVT_IER,
385 SWITCHTEC_PFF_EVT_THRESH,
386 SWITCHTEC_PFF_EVT_POWER_MGMT,
387 SWITCHTEC_PFF_EVT_TLP_THROTTLING,
388 SWITCHTEC_PFF_EVT_FORCE_SPEED,
389 SWITCHTEC_PFF_EVT_CREDIT_TIMEOUT,
390 SWITCHTEC_PFF_EVT_LINK_STATE,
391 SWITCHTEC_GLOBAL_EVT_ASSERT_ERR,
392 SWITCHTEC_MAX_EVENTS,
401 int device,
int func);
403struct switchtec_dev *switchtec_open_i2c_by_adapter(
int adapter,
int i2c_addr);
414 const void *payload,
size_t payload_len,
void *resp,
420 int *partition,
int *port);
430 int index,
int flags,
443int switchtec_set_pax_id(
struct switchtec_dev *dev,
int pax_id);
444int switchtec_echo(
struct switchtec_dev *dev, uint32_t input, uint32_t *output);
447 void (*progress_callback)(
int cur,
int tot));
462 FILE *parsed_log_file,
471 float *sensor_readings);
475 int *phys_port_id,
int *port_lane_id,
478 int lane_id,
int num_lanes,
int *lane_mask,
489 int enable, uint16_t rate);
491 int enable, uint8_t rate);
494 uint16_t seq_num, uint8_t count);
536 return SWITCHTEC_MAX_PORTS_GEN6;
538 return SWITCHTEC_MAX_PORTS;
668 str = (rev == SWITCHTEC_REVA) ?
"REVA" :
669 (rev == SWITCHTEC_REVA1) ?
"REVA.1" :
670 (rev == SWITCHTEC_REVB) ?
"REVB" :
671 (rev == SWITCHTEC_REVC) ?
"REVC" :
"Unknown";
679static inline const char *
683 case SWITCHTEC_GEN3:
return "GEN3";
684 case SWITCHTEC_GEN4:
return "GEN4";
685 case SWITCHTEC_GEN5:
return "GEN5";
686 case SWITCHTEC_GEN6:
return "GEN6";
687 default:
return "UNKNOWN";
717 case SWITCHTEC_BOOT_PHASE_BL1:
719 case SWITCHTEC_BOOT_PHASE_BL2:
721 case SWITCHTEC_BOOT_PHASE_FW:
722 return "Main Firmware";
724 return "Unknown Phase";
733static inline const char *switchtec_ltssm_str_gen4(
int ltssm,
int show_minor)
739 case 0x0000:
return "Detect (INACTIVE)";
740 case 0x0100:
return "Detect (QUIET)";
741 case 0x0200:
return "Detect (SPD_CHD0)";
742 case 0x0300:
return "Detect (SPD_CHD1)";
743 case 0x0400:
return "Detect (ACTIVE0)";
744 case 0x0500:
return "Detect (ACTIVE1)";
745 case 0x0600:
return "Detect (P1_TO_P0)";
746 case 0x0700:
return "Detect (P0_TO_P1_0)";
747 case 0x0800:
return "Detect (P0_TO_P1_1)";
748 case 0x0900:
return "Detect (P0_TO_P1_2)";
749 case 0xFF00:
return "Detect";
750 case 0x0001:
return "Polling (INACTIVE)";
751 case 0x0101:
return "Polling (ACTIVE_ENTRY)";
752 case 0x0201:
return "Polling (ACTIVE)";
753 case 0x0301:
return "Polling (CFG)";
754 case 0x0401:
return "Polling (COMP)";
755 case 0x0501:
return "Polling (COMP_ENTRY)";
756 case 0x0601:
return "Polling (COMP_EIOS)";
757 case 0x0701:
return "Polling (COMP_EIOS_ACK)";
758 case 0x0801:
return "Polling (COMP_IDLE)";
759 case 0xFF01:
return "Polling";
760 case 0x0002:
return "Config (INACTIVE)";
761 case 0x0102:
return "Config (US_LW_START)";
762 case 0x0202:
return "Config (US_LW_ACCEPT)";
763 case 0x0302:
return "Config (US_LN_WAIT)";
764 case 0x0402:
return "Config (US_LN_ACCEPT)";
765 case 0x0502:
return "Config (DS_LW_START)";
766 case 0x0602:
return "Config (DS_LW_ACCEPT)";
767 case 0x0702:
return "Config (DS_LN_WAIT)";
768 case 0x0802:
return "Config (DS_LN_ACCEPT)";
769 case 0x0902:
return "Config (COMPLETE)";
770 case 0x0A02:
return "Config (IDLE)";
771 case 0xFF02:
return "Config";
772 case 0x0003:
return "L0 (INACTIVE)";
773 case 0x0103:
return "L0 (L0)";
774 case 0x0203:
return "L0 (TX_EL_IDLE)";
775 case 0x0303:
return "L0 (TX_IDLE_MIN)";
776 case 0xFF03:
return "L0";
777 case 0x0004:
return "Recovery (INACTIVE)";
778 case 0x0104:
return "Recovery (RCVR_LOCK)";
779 case 0x0204:
return "Recovery (RCVR_CFG)";
780 case 0x0304:
return "Recovery (IDLE)";
781 case 0x0404:
return "Recovery (SPEED0)";
782 case 0x0504:
return "Recovery (SPEED1)";
783 case 0x0604:
return "Recovery (SPEED2)";
784 case 0x0704:
return "Recovery (SPEED3)";
785 case 0x0804:
return "Recovery (EQ_PH0)";
786 case 0x0904:
return "Recovery (EQ_PH1)";
787 case 0x0A04:
return "Recovery (EQ_PH2)";
788 case 0x0B04:
return "Recovery (EQ_PH3)";
789 case 0xFF04:
return "Recovery";
790 case 0x0005:
return "Disable (INACTIVE)";
791 case 0x0105:
return "Disable (DISABLE0)";
792 case 0x0205:
return "Disable (DISABLE1)";
793 case 0x0305:
return "Disable (DISABLE2)";
794 case 0x0405:
return "Disable (DISABLE3)";
795 case 0xFF05:
return "Disable";
796 case 0x0006:
return "Loop Back (INACTIVE)";
797 case 0x0106:
return "Loop Back (ENTRY)";
798 case 0x0206:
return "Loop Back (ENTRY_EXIT)";
799 case 0x0306:
return "Loop Back (EIOS)";
800 case 0x0406:
return "Loop Back (EIOS_ACK)";
801 case 0x0506:
return "Loop Back (IDLE)";
802 case 0x0606:
return "Loop Back (ACTIVE)";
803 case 0x0706:
return "Loop Back (EXIT0)";
804 case 0x0806:
return "Loop Back (EXIT1)";
805 case 0xFF06:
return "Loop Back";
806 case 0x0007:
return "Hot Reset (INACTIVE)";
807 case 0x0107:
return "Hot Reset (HOT_RESET)";
808 case 0x0207:
return "Hot Reset (MASTER_UP)";
809 case 0x0307:
return "Hot Reset (MASTER_DOWN)";
810 case 0xFF07:
return "Hot Reset";
811 case 0x0008:
return "TxL0s (INACTIVE)";
812 case 0x0108:
return "TxL0s (IDLE)";
813 case 0x0208:
return "TxL0s (T0_L0)";
814 case 0x0308:
return "TxL0s (FTS0)";
815 case 0x0408:
return "TxL0s (FTS1)";
816 case 0xFF08:
return "TxL0s";
817 case 0x0009:
return "L1 (INACTIVE)";
818 case 0x0109:
return "L1 (IDLE)";
819 case 0x0209:
return "L1 (SUBSTATE)";
820 case 0x0309:
return "L1 (SPD_CHG1)";
821 case 0x0409:
return "L1 (T0_L0)";
822 case 0xFF09:
return "L1";
823 case 0x000A:
return "L2 (INACTIVE)";
824 case 0x010A:
return "L2 (IDLE)";
825 case 0x020A:
return "L2 (TX_WAKE0)";
826 case 0x030A:
return "L2 (TX_WAKE1)";
827 case 0x040A:
return "L2 (EXIT)";
828 case 0x050A:
return "L2 (SPEED)";
829 case 0xFF0A:
return "L2";
830 default:
return "UNKNOWN";
835static inline const char *switchtec_ltssm_str_gen5(
int ltssm,
int show_minor)
841 case 0x0000:
return "Detect (INACTIVE)";
842 case 0x0100:
return "Detect (QUIET)";
843 case 0x0200:
return "Detect (SPD_CHG0)";
844 case 0x0300:
return "Detect (SPD_CHG1)";
845 case 0x0400:
return "Detect (ACTIVE0)";
846 case 0x0500:
return "Detect (ACTIVE1)";
847 case 0x0600:
return "Detect (ACTIVE2)";
848 case 0x0700:
return "Detect (P1_TO_P0)";
849 case 0x0800:
return "Detect (P0_TO_P1_0)";
850 case 0x0900:
return "Detect (P0_TO_P1_1)";
851 case 0x0A00:
return "Detect (P0_TO_P1_2)";
852 case 0xFF00:
return "Detect";
853 case 0x0001:
return "Polling (INACTIVE)";
854 case 0x0101:
return "Polling (ACTIVE_ENTRY)";
855 case 0x0201:
return "Polling (ACTIVE)";
856 case 0x0301:
return "Polling (CFG)";
857 case 0x0401:
return "Polling (COMP)";
858 case 0x0501:
return "Polling (COMP_ENTRY)";
859 case 0x0601:
return "Polling (COMP_EIOS)";
860 case 0x0701:
return "Polling (COMP_EIOS_ACK)";
861 case 0x0801:
return "Polling (COMP_IDLE)";
862 case 0xFF01:
return "Polling";
863 case 0x0002:
return "Config (INACTIVE)";
864 case 0x0102:
return "Config (US_LW_START)";
865 case 0x0202:
return "Config (US_LW_ACCEPT)";
866 case 0x0302:
return "Config (US_LN_WAIT)";
867 case 0x0402:
return "Config (US_LN_ACCEPT)";
868 case 0x0502:
return "Config (DS_LW_START)";
869 case 0x0602:
return "Config (DS_LW_ACCEPT)";
870 case 0x0702:
return "Config (DS_LN_WAIT)";
871 case 0x0802:
return "Config (DS_LN_ACCEPT)";
872 case 0x0902:
return "Config (COMPLETE)";
873 case 0x0A02:
return "Config (IDLE)";
874 case 0xFF02:
return "Config";
875 case 0x0003:
return "L0 (INACTIVE)";
876 case 0x0103:
return "L0 (L0)";
877 case 0x0203:
return "L0 (TX_EL_IDLE)";
878 case 0x0303:
return "L0 (TX_IDLE_MIN)";
879 case 0xFF03:
return "L0";
880 case 0x0004:
return "Recovery (INACTIVE)";
881 case 0x0104:
return "Recovery (RCVR_LOCK)";
882 case 0x0204:
return "Recovery (RCVR_CFG)";
883 case 0x0304:
return "Recovery (IDLE)";
884 case 0x0404:
return "Recovery (SPEED0)";
885 case 0x0504:
return "Recovery (SPEED1)";
886 case 0x0604:
return "Recovery (SPEED2)";
887 case 0x0704:
return "Recovery (SPEED3)";
888 case 0x0804:
return "Recovery (EQ_PH0)";
889 case 0x0904:
return "Recovery (EQ_PH1)";
890 case 0x0A04:
return "Recovery (EQ_PH2)";
891 case 0x0B04:
return "Recovery (EQ_PH3)";
892 case 0xFF04:
return "Recovery";
893 case 0x0005:
return "Disable (INACTIVE)";
894 case 0x0105:
return "Disable (DISABLE0)";
895 case 0x0205:
return "Disable (DISABLE1)";
896 case 0x0305:
return "Disable (DISABLE2)";
897 case 0x0405:
return "Disable (DISABLE3)";
898 case 0xFF05:
return "Disable";
899 case 0x0006:
return "Loop Back (INACTIVE)";
900 case 0x0106:
return "Loop Back (ENTRY)";
901 case 0x0206:
return "Loop Back (ENTRY_EXIT)";
902 case 0x0306:
return "Loop Back (EIOS)";
903 case 0x0406:
return "Loop Back (EIOS_ACK)";
904 case 0x0506:
return "Loop Back (IDLE)";
905 case 0x0606:
return "Loop Back (ACTIVE)";
906 case 0x0706:
return "Loop Back (EXIT0)";
907 case 0x0806:
return "Loop Back (EXIT1)";
908 case 0xFF06:
return "Loop Back";
909 case 0x0007:
return "Hot Reset (INACTIVE)";
910 case 0x0107:
return "Hot Reset (HOT_RESET)";
911 case 0x0207:
return "Hot Reset (MASTER_UP)";
912 case 0x0307:
return "Hot Reset (MASTER_DOWN)";
913 case 0xFF07:
return "Hot Reset";
914 case 0x0008:
return "TxL0s (INACTIVE)";
915 case 0x0108:
return "TxL0s (IDLE)";
916 case 0x0208:
return "TxL0s (T0_L0)";
917 case 0x0308:
return "TxL0s (FTS0)";
918 case 0x0408:
return "TxL0s (FTS1)";
919 case 0xFF08:
return "TxL0s";
920 case 0x0009:
return "L1 (INACTIVE)";
921 case 0x0109:
return "L1 (IDLE)";
922 case 0x0209:
return "L1 (SUBSTATE)";
923 case 0x0309:
return "L1 (TO_L0)";
924 case 0xFF09:
return "L1";
925 case 0x000A:
return "L2 (INACTIVE)";
926 case 0x010A:
return "L2 (IDLE)";
927 case 0x020A:
return "L2 (TX_WAKE0)";
928 case 0x030A:
return "L2 (TX_WAKE1)";
929 case 0x040A:
return "L2 (EXIT)";
930 case 0x050A:
return "L2 (SPEED)";
931 case 0xFF0A:
return "L2";
932 default:
return "UNKNOWN";
936static inline const char *switchtec_ltssm_str_gen6(
int ltssm_major)
938 switch(ltssm_major) {
939 case 0x00:
return "Detect (QUIET)";
940 case 0x01:
return "Detect (ACTIVE)";
941 case 0x02:
return "Polling (ACTIVE)";
942 case 0x03:
return "Polling (COMPLIANCE)";
943 case 0x04:
return "Polling (CONFIG)";
944 case 0x05:
return "Detect (PRE_DETECT_QUIET)";
945 case 0x06:
return "Detect (DETECT_WAIT)";
946 case 0x07:
return "Configuration (LINKWD_START)";
947 case 0x08:
return "Configuration (LINKWD_ACCEPT)";
948 case 0x09:
return "Configuration (LANENUM_WAIT)";
949 case 0x0A:
return "Configuration (LANENUM_ACCEPT)";
950 case 0x0B:
return "Configuration (COMPLETE)";
951 case 0x0C:
return "Configuration (IDLE)";
952 case 0x0D:
return "Recovery (LOCK)";
953 case 0x0E:
return "Recovery (SPEED)";
954 case 0x0F:
return "Recovery (RCVRCFG)";
955 case 0x10:
return "Recovery (IDLE)";
956 case 0x11:
return "L0 (ACTIVE)";
957 case 0x12:
return "L0s (IDLE)";
958 case 0x13:
return "L1/L2/L3 (SEND_EIDLE)";
959 case 0x14:
return "L1 (IDLE)";
960 case 0x15:
return "L2 (IDLE)";
961 case 0x16:
return "L2 (WAKE)";
962 case 0x17:
return "Disabled (ENTRY)";
963 case 0x18:
return "Disabled (IDLE)";
964 case 0x19:
return "Disabled";
965 case 0x1A:
return "Loopback (ENTRY)";
966 case 0x1B:
return "Loopback (ACTIVE)";
967 case 0x1C:
return "Loopback (EXIT)";
968 case 0x1D:
return "Loopback (EXIT_TIMEOUT)";
969 case 0x1E:
return "Hot Reset (ENTRY)";
970 case 0x1F:
return "Hot Reset";
971 case 0x20:
return "Recovery (EQ0)";
972 case 0x21:
return "Recovery (EQ1)";
973 case 0x22:
return "Recovery (EQ2)";
974 case 0x23:
return "Recovery (EQ3)";
975 default:
return "UNKNOWN";
979static inline const char *switchtec_ltssm_str(
int ltssm,
int show_minor,
980 struct switchtec_dev *dev)
983 return switchtec_ltssm_str_gen6(ltssm);
985 return switchtec_ltssm_str_gen5(ltssm, show_minor);
987 return switchtec_ltssm_str_gen4(ltssm, show_minor);
997 SWITCHTEC_EVT_FLAG_CLEAR = 1 << 0,
998 SWITCHTEC_EVT_FLAG_EN_POLL = 1 << 1,
999 SWITCHTEC_EVT_FLAG_EN_LOG = 1 << 2,
1000 SWITCHTEC_EVT_FLAG_EN_CLI = 1 << 3,
1001 SWITCHTEC_EVT_FLAG_EN_FATAL = 1 << 4,
1002 SWITCHTEC_EVT_FLAG_DIS_POLL = 1 << 5,
1003 SWITCHTEC_EVT_FLAG_DIS_LOG = 1 << 6,
1004 SWITCHTEC_EVT_FLAG_DIS_CLI = 1 << 7,
1005 SWITCHTEC_EVT_FLAG_DIS_FATAL = 1 << 8,
1016 SWITCHTEC_EVT_IDX_LOCAL = -1,
1017 SWITCHTEC_EVT_IDX_ALL = -2,
1025 SWITCHTEC_EVT_GLOBAL,
1055 SWITCHTEC_DLSTAT_READY = 0x0,
1056 SWITCHTEC_DLSTAT_INPROGRESS = 0x1,
1057 SWITCHTEC_DLSTAT_HEADER_INCORRECT = 0x2,
1058 SWITCHTEC_DLSTAT_OFFSET_INCORRECT = 0x3,
1059 SWITCHTEC_DLSTAT_CRC_INCORRECT = 0x4,
1060 SWITCHTEC_DLSTAT_LENGTH_INCORRECT = 0x5,
1061 SWITCHTEC_DLSTAT_HARDWARE_ERR = 0x6,
1062 SWITCHTEC_DLSTAT_COMPLETES = 0x7,
1063 SWITCHTEC_DLSTAT_SUCCESS_FIRM_ACT = 0x8,
1064 SWITCHTEC_DLSTAT_SUCCESS_DATA_ACT = 0x9,
1065 SWITCHTEC_DLSTAT_PACKAGE_TOO_SMALL = 0xa,
1066 SWITCHTEC_DLSTAT_SIG_MEM_ALLOC = 0xb,
1067 SWITCHTEC_DLSTAT_SEEPROM = 0xc,
1068 SWITCHTEC_DLSTAT_READONLY_PARTITION = 0xd,
1069 SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT = 0xe,
1070 SWITCHTEC_DLSTAT_SEEPROM_TWI_NOT_ENABLED = 0xf,
1071 SWITCHTEC_DLSTAT_PROGRAM_RUNNING = 0x10,
1072 SWITCHTEC_DLSTAT_NOT_ALLOWED = 0x11,
1073 SWITCHTEC_DLSTAT_XML_MISMATCH_ACT = 0x12,
1074 SWITCHTEC_DLSTAT_UNKNOWN_ACT = 0x13,
1076 SWITCHTEC_DLSTAT_ERROR_PROGRAM = 0x1000,
1077 SWITCHTEC_DLSTAT_ERROR_OFFSET = 0x1001,
1079 SWITCHTEC_DLSTAT_NO_FILE = 0x7d009,
1086 SWITCHTEC_FW_RW = 0,
1087 SWITCHTEC_FW_RO = 1,
1091 int keyman,
int riot,
1092 int bl2,
int cfg,
int fw,
1095 int toggle_bl2,
int toggle_key,
1096 int toggle_fw,
int toggle_cfg,
1097 int toggle_riotcore);
1099 int dont_activate,
int force,
1100 void (*progress_callback)(
int cur,
int tot));
1102 int dont_activate,
int force,
1103 void (*progress_callback)(
int cur,
int tot));
1105 unsigned long addr,
size_t len,
1106 void (*progress_callback)(
int cur,
int tot));
1109 void (*progress_callback)(
int cur,
int tot));
1111 size_t len,
void *buf);
1116int switchtec_get_device_id_bl2(
struct switchtec_dev *dev,
1117 unsigned short *device_id);
1130int switchtec_bind_info(
struct switchtec_dev *dev,
1133int switchtec_bind(
struct switchtec_dev *dev,
int par_id,
1134 int log_port,
int phy_port);
1135int switchtec_unbind(
struct switchtec_dev *dev,
int par_id,
int log_port);
1141 int port_bif[SWITCHTEC_PORTS_PER_STACK]);
1143 int port_bif[SWITCHTEC_PORTS_PER_STACK]);
1147 uint8_t reserved[3];
1148 uint64_t rtc_counter;
1166 uint16_t slave_addr;
1168 uint16_t num_of_bytes;
1169 uint8_t slave_addr_size;
1170 uint8_t offset_size;
1177 uint8_t master_recov;
1179 uint32_t duration_ms;
1183 TWI_ACCESS_READ = 0,
1189 uint16_t slave_addr, uint32_t offset,
1190 uint8_t offset_size, uint8_t slave_addr_size,
1191 uint16_t num_bytes, uint32_t *data);
1193 uint16_t slave_addr, uint32_t offset,
1194 uint8_t offset_size, uint8_t slave_addr_size,
1195 uint16_t num_bytes, uint32_t *output);
1197 uint8_t twi_port, uint32_t duration_ms);
1204 uint16_t log_gpio_id;
1213 uint32_t pin_values[SWITCHTEC_MAX_GPIO_PIN_VALS];
1311 unsigned cntr_id,
unsigned nr_cntrs,
1314 unsigned cntr_id,
unsigned nr_cntrs,
unsigned *res,
1317 unsigned cntr_id,
unsigned nr_cntrs,
1319 unsigned *counts,
int clear);
1340 int * phys_port_ids,
1345 int *phys_port_ids,
int clear,
1354#define SWITCHTEC_LAT_ALL_INGRESS 63
1357 int *egress_port_ids,
int *ingress_port_ids);
1359 int ingress_port_id,
int clear);
1361 int clear,
int *egress_port_ids,
1362 int *cur_ns,
int *max_ns);
1364 int egress_port_ids,
int *cur_ns,
1383#define SWITCHTEC_DIAG_CROSS_HAIR_ALL_LANES -1
1384#define SWITCHTEC_DIAG_CROSS_HAIR_MAX_LANES 64
1386enum switchtec_diag_cross_hair_state {
1387 SWITCHTEC_DIAG_CROSS_HAIR_DISABLED = 0,
1388 SWITCHTEC_DIAG_CROSS_HAIR_RESVD,
1389 SWITCHTEC_DIAG_CROSS_HAIR_WAITING,
1390 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_RIGHT,
1391 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_RIGHT,
1392 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_RIGHT,
1393 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_LEFT,
1394 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_LEFT,
1395 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_LEFT,
1396 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_TOP_RIGHT,
1397 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_TOP_RIGHT,
1398 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_TOP_RIGHT,
1399 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_BOT_RIGHT,
1400 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_BOT_RIGHT,
1401 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_BOT_RIGHT,
1402 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_TOP_LEFT,
1403 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_TOP_LEFT,
1404 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_TOP_LEFT,
1405 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_BOT_LEFT,
1406 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_BOT_LEFT,
1407 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_BOT_LEFT,
1408 SWITCHTEC_DIAG_CROSS_HAIR_DONE,
1409 SWITCHTEC_DIAG_CROSS_HAIR_ERROR,
1413 enum switchtec_diag_cross_hair_state state;
1427 int eye_bot_left_lim;
1428 int eye_bot_right_lim;
1429 int eye_top_left_lim;
1430 int eye_top_right_lim;
1439 int target_amplitude;
1440 int speculative_dfe;
1446 uint8_t reserved[3];
1455 uint8_t reserved[3];
1484 uint8_t phys_port_id;
1488 uint8_t reserved[2];
1517 uint8_t reserved[2];
1521 uint8_t post_cursor;
1522 uint16_t reserved_0;
1524 uint8_t error_status;
1525 uint8_t active_status;
1538 uint8_t reserved[2];
1547 uint8_t reserved[3];
1563enum switchtec_diag_eye_data_mode {
1564 SWITCHTEC_DIAG_EYE_RAW,
1565 SWITCHTEC_DIAG_EYE_RATIO,
1568enum switchtec_diag_eye_data_mode_gen6 {
1569 SWITCHTEC_DIAG_EYE_ADC,
1570 SWITCHTEC_DIAG_EYE_FFE,
1571 SWITCHTEC_DIAG_EYE_DFE,
1574enum switchtec_diag_eye_mode_gen6 {
1575 SWITCHTEC_DIAG_EYE_FULL,
1576 SWITCHTEC_DIAG_EYE_INTERLEAVE,
1577 SWITCHTEC_DIAG_EYE_SAR,
1580enum switchtec_diag_eye_h_step {
1581 SWITCHTEC_DIAG_EYE_ULTRA_FINE = 1,
1582 SWITCHTEC_DIAG_EYE_FINE = 2,
1583 SWITCHTEC_DIAG_EYE_MEDIUM = 3,
1584 SWITCHTEC_DIAG_EYE_COARSE = 4,
1608 uint64_t ber_data[60];
1621 uint32_t ndes_data[64];
1624enum switchtec_diag_loopback_enable {
1625 SWITCHTEC_DIAG_LOOPBACK_RX_TO_TX = 1 << 0,
1626 SWITCHTEC_DIAG_LOOPBACK_TX_TO_RX = 1 << 1,
1627 SWITCHTEC_DIAG_LOOPBACK_LTSSM = 1 << 2,
1628 SWITCHTEC_DIAG_LOOPBACK_PIPE = 1 << 3,
1631enum switchtec_diag_pattern {
1632 SWITCHTEC_DIAG_PATTERN_PRBS_7,
1633 SWITCHTEC_DIAG_PATTERN_PRBS_11,
1634 SWITCHTEC_DIAG_PATTERN_PRBS_23,
1635 SWITCHTEC_DIAG_PATTERN_PRBS_31,
1636 SWITCHTEC_DIAG_PATTERN_PRBS_9,
1637 SWITCHTEC_DIAG_PATTERN_PRBS_15,
1638 SWITCHTEC_DIAG_PATTERN_PRBS_DISABLED,
1641enum switchtec_diag_pattern_gen5 {
1642 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_7,
1643 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_11,
1644 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_23,
1645 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_31,
1646 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_9,
1647 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_15,
1648 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_5,
1649 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_20,
1650 SWITCHTEC_DIAG_GEN_5_RESERVED_0,
1651 SWITCHTEC_DIAG_GEN_5_RESERVED_1,
1652 SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_DISABLED,
1655enum switchtec_diag_pattern_gen6 {
1656 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_7 = 0x0,
1657 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_11 = 0x1,
1658 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_23 = 0x2,
1659 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_31 = 0x3,
1660 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_9 = 0x4,
1661 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_15 = 0x5,
1662 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_5 = 0x6,
1663 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_20 = 0x7,
1664 SWITCHTEC_DIAG_GEN_6_PATTERN_CJPAT = 0x8,
1665 SWITCHTEC_DIAG_GEN_6_PATTERN_CJTPAT = 0x9,
1666 SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_DISABLED = 0xA,
1669enum switchtec_diag_pattern_link_rate {
1670 SWITCHTEC_DIAG_PAT_LINK_DISABLED = 0,
1671 SWITCHTEC_DIAG_PAT_LINK_GEN1 = 1,
1672 SWITCHTEC_DIAG_PAT_LINK_GEN2 = 2,
1673 SWITCHTEC_DIAG_PAT_LINK_GEN3 = 3,
1674 SWITCHTEC_DIAG_PAT_LINK_GEN4 = 4,
1675 SWITCHTEC_DIAG_PAT_LINK_GEN5 = 5,
1676 SWITCHTEC_DIAG_PAT_LINK_GEN6 = 6,
1679enum switchtec_diag_ltssm_speed {
1680 SWITCHTEC_DIAG_LTSSM_GEN1 = 0,
1681 SWITCHTEC_DIAG_LTSSM_GEN2 = 1,
1682 SWITCHTEC_DIAG_LTSSM_GEN3 = 2,
1683 SWITCHTEC_DIAG_LTSSM_GEN4 = 3,
1684 SWITCHTEC_DIAG_LTSSM_GEN5 = 4,
1685 SWITCHTEC_DIAG_LTSSM_GEN6 = 5,
1688enum switchtec_diag_end {
1689 SWITCHTEC_DIAG_LOCAL,
1690 SWITCHTEC_DIAG_FAR_END,
1693enum switchtec_diag_link {
1694 SWITCHTEC_DIAG_LINK_CURRENT,
1695 SWITCHTEC_DIAG_LINK_PREVIOUS,
1698enum switchtec_gen5_diag_eye_status {
1699 SWITCHTEC_GEN5_DIAG_EYE_STATUS_IDLE = 0,
1700 SWITCHTEC_GEN5_DIAG_EYE_STATUS_PENDING = 1,
1701 SWITCHTEC_GEN5_DIAG_EYE_STATUS_IN_PROGRESS = 2,
1702 SWITCHTEC_GEN5_DIAG_EYE_STATUS_DONE = 3,
1703 SWITCHTEC_GEN5_DIAG_EYE_STATUS_TIMEOUT = 4,
1704 SWITCHTEC_GEN5_DIAG_EYE_STATUS_ERROR = 5,
1708 unsigned int timestamp;
1722 uint8_t trigger_lane;
1723 uint8_t trigger_dir;
1724 uint16_t trigger_reason;
1732 uint16_t os_type_lane_mask;
1733 uint8_t os_type_direction;
1734 uint8_t os_type_link_rate;
1735 uint16_t os_type_os_types;
1738 uint16_t os_pat_lane_mask;
1739 uint8_t os_pat_direction;
1740 uint8_t os_pat_link_rate;
1741 uint32_t os_pat_value[4];
1742 uint32_t os_pat_mask[4];
1745 uint8_t misc_trig_enable;
1748 uint16_t capture_lane_mask;
1749 uint8_t capture_direction;
1750 uint8_t capture_drop_single_os;
1751 uint8_t capture_stop_mode;
1752 uint8_t capture_snapshot_mode;
1753 uint16_t capture_post_trig_entries;
1754 uint16_t capture_os_types;
1764 uint8_t trigger_indication;
1766 uint32_t osa_data[4];
1772#define SWITCHTEC_OSA_MAX_ENTRIES 1024
1777 uint16_t total_entries;
1778 uint8_t wrap_occurred;
1779 uint16_t entry_count;
1789 enum switchtec_diag_eye_data_mode mode);
1791 int* num_phases,
double* ber_data);
1793 struct range *x_range,
struct range *y_range,
1794 int step_interval,
int capture_depth,
int sar_sel,
1795 int intleav_sel,
int hstep,
int data_mode,
1796 int eye_mode, uint64_t refclk,
int vstep);
1798 size_t pixel_cnt,
int *lane_id);
1802 int enable,
int enable_parallel,
1803 int enable_external,
int enable_ltssm,
1805 enum switchtec_diag_ltssm_speed ltssm_speed);
1808 enum switchtec_diag_ltssm_speed *ltssm_speed);
1810 enum switchtec_diag_pattern type,
1811 enum switchtec_diag_pattern_link_rate
1814 enum switchtec_diag_pattern *type);
1816 enum switchtec_diag_pattern type);
1819 enum switchtec_diag_pattern *type,
1820 unsigned long long *err_cnt);
1822 unsigned int err_cnt);
1825 int lane_id,
enum switchtec_diag_link link,
1828 int lane_id,
enum switchtec_diag_link link,
1832 int prev_speed,
enum switchtec_diag_end end,
1833 enum switchtec_diag_link link,
1837 enum switchtec_diag_link link,
1840 int prev_speed,
int lane_id,
1841 enum switchtec_diag_end end,
1842 enum switchtec_diag_link link,
1851 int port,
int *log_count,
1853int switchtec_tlp_inject(
struct switchtec_dev * dev,
int port_id,
int tlp_type,
1854 int tlp_length,
int ecrc, uint32_t * raw_tlp_data);
1856 int aer_error_id,
int trigger_event);
1857int switchtec_osa(
struct switchtec_dev * dev,
int stack_id,
int operation,
1859int switchtec_osa_config_type(
struct switchtec_dev * dev,
int stack_id,
1860 int direction,
int lane_mask,
int link_rate,
1862int switchtec_osa_config_misc(
struct switchtec_dev * dev,
int stack_id,
1864int switchtec_osa_capture_control(
struct switchtec_dev * dev,
int stack_id,
1865 int lane_mask,
int direction,
1866 int drop_single_os,
int stop_mode,
1867 int snapshot_mode,
int post_trigger,
1869int switchtec_osa_dump_conf(
struct switchtec_dev * dev,
int stack_id,
1871int switchtec_osa_config_pattern(
struct switchtec_dev * dev,
int stack_id,
1872 int direction,
int lane_mask,
int link_rate,
1873 uint32_t * value_data, uint32_t * mask_data);
1875 int lane,
int direction,
struct switchtec_dev * switchtec_open(const char *device)
Open a Switchtec device by string.
void switchtec_list_free(struct switchtec_device_info *devlist)
Free a list of device info structures allocated by switchtec_list().
struct switchtec_dev * switchtec_open_uart(int fd)
Open a switchtec device behind a uart device.
int switchtec_list(struct switchtec_device_info **devlist)
List all the switchtec devices in the system.
struct switchtec_dev * switchtec_open_by_index(int index)
Open a switchtec device by index.
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.
void switchtec_close(struct switchtec_dev *dev)
Close a Switchtec device handle.
void switchtec_perror(const char *str)
Print an error string to stdout.
struct switchtec_dev * switchtec_open_i2c(const char *path, int i2c_addr)
Open a switchtec device behind an I2C device.
void switchtec_status_free(struct switchtec_status *status, int ports)
Free a list of status structures allocated by switchtec_status().
int switchtec_status(struct switchtec_dev *dev, struct switchtec_status **status)
Get the status of all the ports on a switchtec device.
struct switchtec_dev * switchtec_open_by_path(const char *path)
Open a switchtec device by path.
_PURE const char * switchtec_name(struct switchtec_dev *dev)
Get the string that was used to open the deviec.
const char * switchtec_strerror(void)
Return a message coresponding to the last error.
_PURE int switchtec_device_id(struct switchtec_dev *dev)
Get the device id of the device.
struct switchtec_dev * switchtec_open_eth(const char *ip, const int inst)
Open a switchtec device over ethernet.
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_get_device_version(struct switchtec_dev *dev, int *res)
Get the minor version number as a user readable int.
_PURE int switchtec_partition(struct switchtec_dev *dev)
Get the partiton number of the device that was opened.
int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf, size_t buflen)
Get the firmware version as a user readable string.
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_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.
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...
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_event_summary_iter(struct switchtec_dev *dev, struct switchtec_event_summary *sum, enum switchtec_event_id *e, int *idx)
Iterate through all set bits in an event summary structure.
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(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_wait(struct switchtec_dev *dev, int timeout_ms)
Wait for any event to occur (typically just an interrupt).
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_check(struct switchtec_dev *dev, struct switchtec_event_summary *check, struct switchtec_event_summary *res)
Check if one or more events have occurred.
enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version)
Extract generation information from FW version number.
int switchtec_fw_img_get(struct switchtec_dev *dev, int fd, enum switchtec_fw_type_gen6 fw_type, int fw_slot, void(*progress_callback)(int cur, int tot))
Download fwimg file from device.
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_read(struct switchtec_dev *dev, unsigned long addr, size_t len, void *buf)
Read a Switchtec device's flash data.
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_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.
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.
struct switchtec_fw_image_info * switchtec_fw_part_data_bl2(struct switchtec_dev *dev)
Return the firmware image information using supported metadata MRPC commands for the gen6 BL2 phase.
int switchtec_sms_fmc_version_get(struct switchtec_dev *dev, uint32_t *info)
Return firmware summary information structure for the flash partitfons in the device.
int switchtec_fw_is_boot_ro(struct switchtec_dev *dev)
Check if the boot partition is marked as read-only.
int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info)
Retrieve information about a firmware image file.
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.
void switchtec_fw_perror(const char *s, int ret)
Print an error string to stdout.
void switchtec_fw_image_info_free(struct switchtec_fw_image_info *inf)
Free a firmware image info data structure.
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.
void switchtec_fw_part_summary_free(struct switchtec_fw_part_summary *summary)
Free a firmware part summary data structure.
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.
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_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.
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_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_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_get_gpio(struct switchtec_dev *dev, int pin_id, int *gpio_val)
Get the GPIO pin value.
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_twi_access_reset(struct switchtec_dev *dev, uint8_t master_recov, uint8_t twi_port, uint32_t duration_ms)
Reset the TWI bus using TWI Access MRPC.
int switchtec_set_gpio(struct switchtec_dev *dev, int pin_id, int gpio_val)
Set the GPIO pin value.
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_get_gpio_polarity_cfg(struct switchtec_dev *dev, int pin_id, int *polarity)
Get the GPIO pin polarity.
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.
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_rtc_counter_set(struct switchtec_dev *dev, uint64_t *rtc_counter)
Set the RTC counter.
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_twi_access_write(struct switchtec_dev *dev, uint8_t twi_port, uint16_t slave_addr, uint32_t offset, uint8_t offset_size, uint8_t slave_addr_size, uint16_t num_bytes, uint32_t *data)
Write to the TWI bus using TWI Access MRPC.
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_hard_reset(struct switchtec_dev *dev)
Perform an MRPC hard reset command.
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_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.
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.
int switchtec_twi_access_read(struct switchtec_dev *dev, uint8_t twi_port, uint16_t slave_addr, uint32_t offset, uint8_t offset_size, uint8_t slave_addr_size, uint16_t num_bytes, uint32_t *output)
Read from the TWI bus using TWI Access MRPC.
int switchtec_en_dis_interrupt(struct switchtec_dev *dev, int pin_id, int en)
Enable/Disable the GPIO pin interrupt.
int switchtec_rtc_counter_reset(struct switchtec_dev *dev)
Perform a reset operation on the RTC counter.
int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output)
Perform an MRPC echo command.
int switchtec_get_all_pin_sts(struct switchtec_dev *dev, uint32_t *values)
Get all GPIO pin status.
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_rtc_counter_get(struct switchtec_dev *dev, uint64_t *rtc_counter)
Get the RTC counter.
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_get_gpio_direction_cfg(struct switchtec_dev *dev, int pin_id, int *direction)
Get the GPIO pin direction.
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.
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_type_count(void)
Get the number of event counter types.
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.
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_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_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_evcntr_wait(struct switchtec_dev *dev, int timeout_ms)
Block until any event counter has reached its threshold.
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_lat_setup(struct switchtec_dev *dev, int egress_port_id, int ingress_port_id, int clear)
Setup a latency counter.
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_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_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_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_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_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.
uint64_t comp
Completion TLP bytes.
uint64_t posted
Posted TLP bytes.
uint64_t nonposted
Non-Posted TLP bytes.
Bandwidth counter result struct.
struct switchtec_bwcntr_res::switchtec_bwcntr_dir ingress
Bandwidth into the port.
uint64_t time_us
Time (in microseconds).
struct switchtec_bwcntr_res::switchtec_bwcntr_dir egress
Bandwidth out of the port.
Represents a Switchtec device in the switchtec_list() function.
char fw_version[32]
Firmware version.
char pci_dev[256]
PCI BDF string.
char desc[256]
Device description, if available.
char path[PATH_MAX]
Path to the device.
char name[256]
Device name, eg. switchtec0.
char product_id[32]
Product ID.
char product_rev[8]
Product revision.
Structure used to setup an event counter.
unsigned threshold
Threshold to count to before generating an interrupt.
enum switchtec_evcntr_type_mask type_mask
Event counter types to count.
Null-terminated list of all event counter types with a name and help text.
uint64_t part_bitmap
Bitmap of partitions with active events.
uint64_t global
Bitmap of global events.
unsigned part[SWITCHTEC_MAX_PARTS]
Bitmap of events in each partition.
unsigned local_part
Bitmap of events in the local partition.
unsigned pff[SWITCHTEC_MAX_PFF_CSR]
Bitmap of events in each port function.
Information about a firmware image or partition.
enum switchtec_gen gen
Image generation.
size_t part_body_offset
Partition image body offset.
unsigned long image_crc
CRC checksum of the image.
char version[32]
Firmware/Config version.
size_t image_len
Length of the image.
unsigned long part_id
Image partition ID.
size_t part_addr
Address of the partition.
size_t part_len
Length of the partition.
enum switchtec_fw_type type
Image partition type.
Information about log file and log definition file.
OSA configuration dump result.
unsigned char upstream
1 if this is an upstream port
unsigned char partition
Partition the port is in.
unsigned char stk_id
Port number within the stack.
unsigned char log_id
Logical port number.
unsigned char phys_id
Physical port number.
unsigned char stack
Stack number.
struct switchtec_port_id port
Port ID.
unsigned char link_up
1 if the link is up
unsigned char lane_reversal
Lane reversal.
unsigned int acs_ctrl
ACS Setting of the Port.
const char * lane_reversal_str
Lane reversal as a string.
unsigned char cfg_lnk_width
Configured link width.
unsigned char link_rate
Link rate/gen.
unsigned char first_act_lane
First active lane.
unsigned char neg_lnk_width
Negotiated link width.
uint16_t ltssm
Link state.
char * pci_bdf_path
PCI BDF path of the port.
char * pci_bdf
PCI BDF of the port.
char * class_devices
Comma seperated list of classes.
char * pci_dev
PCI BDF of the device on the port.
const char * ltssm_str
Link state as a string.
switchtec_bw_type
The types of bandwidth.
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.
@ LANE_EQ_DUMP_TYPE_NUM
Total number of dump types.
@ LANE_EQ_DUMP_TYPE_PREV
Previous link-up settings.
@ LANE_EQ_DUMP_TYPE_CURR
Current settings.
static int switchtec_is_pfxl(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-L.
switchtec_log_parse_type
Log types to parse.
int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev)
Disable active cross hair.
switchtec_event_id
Enumeration of all possible events.
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_gen_get(struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern *type)
Get Pattern Generator set on port.
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.
static int switchtec_is_psxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX-A.
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_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_diag_eye_read(struct switchtec_dev *dev, int lane_id, int bin, int *num_phases, double *ber_data)
Start a PCIe Eye Read Gen5.
switchtec_fw_ro
Flag which indicates if a partition is read-only or not.
switchtec_rev
Device hardware revision.
int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels, size_t pixel_cnt, int *lane_id)
Start a PCIe Eye Capture.
static int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX or PSX.
switchtec_evcntr_type_mask
Event counter type mask (may be or-d together).
@ ALL_TLPS
Mask indicating all TLP types.
@ RCVR_ERR
Receiver Error.
@ RCVR_OFLOW_ERR
Receiver Overflow Error.
@ REPLAY_NUM_ROLLOVER
Replay Number Rollover.
@ COMP_TLP
Completion TLP.
@ NON_POSTED_TLP
Non-Posted TLP.
@ SURPRISE_DOWN_ERR
Surprise Down Error.
@ POISONED_TLP_ERR
Poisoned TLP Error.
@ ALL_ERRORS
Mask indicating all possible errors.
@ RCV_CORR_MSG
Receive Correctable Error Message.
@ RCV_NON_FATAL_MSG
Receive Non-FATAL Error Message.
@ UNSUP_REQ_ERR
Unsupported Request Error.
@ RULE_TABLE_HIT
Rule Search Table Rule Hit.
@ ALL
Mask indicating all event types.
@ REPLAY_TMR_TIMEOUT
Replay Timer Timeout.
@ HDR_LOG_OFLOW_ERR
Header Log Overflow Error.
@ DATA_LINK_PROTO_ERR
Data Link Protocol Error.
@ UNCOR_INT_ERR
Uncorrectable Internal Error.
@ CMPLTR_ABORT_ERR
Completer Abort Error.
@ RCV_FATAL_MSG
Receive FATAL Error Message.
@ MALFORM_TLP_ERR
Malformed TLP Error.
int switchtec_diag_pattern_inject(struct switchtec_dev *dev, int port_id, unsigned int err_cnt)
Inject error into pattern generator.
static const char * switchtec_rev_str(enum switchtec_rev rev)
Return the revision string.
static const char * switchtec_gen_str(struct switchtec_dev *dev)
Return the generation string of a Switchtec device.
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_pfxi(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-I.
switchtec_gen
The PCIe generations.
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_eye_start(struct switchtec_dev *dev, int lane_mask[4], struct range *x_range, struct range *y_range, int step_interval, int capture_depth, int sar_sel, int intleav_sel, int hstep, int data_mode, int eye_mode, uint64_t refclk, int vstep)
Start a PCIe Eye Capture.
@ PCIE_LINK_RATE_GEN3
Gen3, supports 2.5GT/s, 5GT/s, 8GT/s.
@ PCIE_LINK_RATE_GEN1
Gen1, supports 2.5GT/s.
@ PCIE_LINK_RATE_GEN4
Gen4, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s.
@ PCIE_LINK_RATE_NUM
Total number of PCIe generations.
@ PCIE_LINK_RATE_GEN5
Gen5, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s, 32GT/s.
@ PCIE_LINK_RATE_GEN6
Gen6, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s, 32GT/s, 64GT/s.
@ PCIE_LINK_RATE_GEN2
Gen2, supports 2.5GT/s, 5GT/s.
@ PCIE_LINK_RATE_INV
Invalid.
static int switchtec_is_psx(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX.
int switchtec_diag_perm_table(struct switchtec_dev *dev, struct switchtec_mrpc table[MRPC_MAX_ID])
Get the permission table.
@ SWITCHTEC_IMG_PART_TYPE_CERT
@ SWITCHTEC_IMG_PART_TYPE_RSVD_13
@ SWITCHTEC_IMG_PART_TYPE_FW
@ SWITCHTEC_IMG_PART_TYPE_RSVD_9
@ SWITCHTEC_IMG_PART_TYPE_RSVD_14
@ SWITCHTEC_IMG_PART_TYPE_DEBUG_TOKEN
@ SWITCHTEC_IMG_PART_TYPE_NUM
@ SWITCHTEC_IMG_PART_TYPE_RSVD_15
@ SWITCHTEC_IMG_PART_TYPE_RSVD_11
@ SWITCHTEC_IMG_PART_TYPE_RSVD_8
@ SWITCHTEC_IMG_PART_TYPE_BL2
@ SWITCHTEC_IMG_PART_TYPE_RSVD_10
@ SWITCHTEC_IMG_PART_TYPE_KMT
@ SWITCHTEC_IMG_PART_TYPE_RSVD_5
@ SWITCHTEC_IMG_PART_TYPE_MAP
@ SWITCHTEC_IMG_PART_TYPE_DATA
@ SWITCHTEC_IMG_PART_TYPE_RSVD_12
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_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.
switchtec_log_def_type
Log definition data types.
int switchtec_diag_refclk_status(struct switchtec_dev *dev, uint8_t *info)
Get the status of all stacks/CSUs of the refclk.
__gas struct switchtec_gas * gasptr_t
Shortform for a pointer to the GAS register space.
switchtec_variant
The variant types of Switchtec device.
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.
static const char * switchtec_phase_id_str(enum switchtec_boot_phase phase_id)
Return the phase string for a phase id.
int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id)
Enable cross hair on specified lane.
static int switchtec_is_gen6(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 6 device.
switchtec_event_type
There are three event types indicated by this enumeration: global, partition and port function.
switchtec_log_type
Describe the type of logs too dump.
switchtec_event_special
Special event indexes numbers.
switchtec_boot_phase
Device boot phase.
static const float switchtec_gen_transfers[]
Number of GT/s capable for each PCI generation or link_rate.
int switchtec_diag_eye_cancel(struct switchtec_dev *dev)
Cancel in-progress eye capture.
static int switchtec_is_gen4(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 4 device.
static int switchtec_is_paxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX-A.
static int switchtec_max_supported_ports(struct switchtec_dev *dev)
Return the max number of ports of a Switchtec device.
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_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_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,...
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_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_loopback_set(struct switchtec_dev *dev, int port_id, int enable, int enable_parallel, int enable_external, int enable_ltssm, int enable_pipe, enum switchtec_diag_ltssm_speed ltssm_speed)
Setup Loopback Mode.
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_pax(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX.
static int switchtec_is_psx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX(A).
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_diag_ltssm_clear(struct switchtec_dev *dev, int port)
Call the LTSSM clear MRPC command.
static int switchtec_is_gen5(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 5 device.
static int switchtec_is_pfx(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX.
switchtec_event_flags
Event control flags.
int switchtec_diag_refclk_ctl(struct switchtec_dev *dev, int id, bool en)
Control the refclk output for a stack or CSU.
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.
switchtec_fw_dlstatus
Firmware update status.
int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern type)
Setup Pattern Monitor.
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 float switchtec_gen_datarate[]
Number of GB/s capable for each PCI generation or link_rate.
static int switchtec_is_pax_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX(A).
#define SWITCHTEC_OSA_MAX_ENTRIES
OSA capture data collection.
static const char * switchtec_variant_str(struct switchtec_dev *dev)
Return the variant string of a Switchtec device.
switchtec_parition_types
Device parition types GEN5.
static int switchtec_is_gen3(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 3 device.