Switchtec Userspace PROJECT_NUMBER = 4.4
Loading...
Searching...
No Matches
switchtec.h
Go to the documentation of this file.
1/*
2 * Microsemi Switchtec(tm) PCIe Management Library
3 * Copyright (c) 2017, Microsemi Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25#ifndef LIBSWITCHTEC_SWITCHTEC_H
26#define LIBSWITCHTEC_SWITCHTEC_H
27
32
33#include "mrpc.h"
34#include "bind.h"
35#include "portable.h"
36#include "registers.h"
37#include "utils.h"
38#include "inject.h"
39
40#include <stdbool.h>
41#include <stdlib.h>
42#include <stdint.h>
43#include <stdio.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49struct switchtec_dev;
50
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
62
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
67
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
72
73#define SWITCHTEC_DIAG_MAX_TLP_DWORDS 132
74
75#define SWITCHTEC_MAX_GPIO_PIN_VALS 30
76
77#ifdef __CHECKER__
78#define __gas __attribute__((noderef, address_space(1)))
79#else
80#define __gas
81#endif
82
83#define _PURE __attribute__ ((pure))
84
88typedef __gas struct switchtec_gas *gasptr_t;
89#define SWITCHTEC_MAP_FAILED ((gasptr_t) -1)
90
95 SWITCHTEC_GEN3,
96 SWITCHTEC_GEN4,
97 SWITCHTEC_GEN5,
98 SWITCHTEC_GEN6,
99 SWITCHTEC_GEN_UNKNOWN,
100};
101
106 SWITCHTEC_REVA = 0x0f,
107 SWITCHTEC_REVA1 = 0x0e,
108 SWITCHTEC_REVB = 0x00,
109 SWITCHTEC_REVC = 0x01,
110 SWITCHTEC_REV_UNKNOWN = 0xff
111};
112
117 SWITCHTEC_BOOT_PHASE_BL1 = 1,
118 SWITCHTEC_BOOT_PHASE_BL2,
119 SWITCHTEC_BOOT_PHASE_FW,
120 SWITCHTEC_BOOT_PHASE_UNKNOWN
121};
122
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
132};
133
138 SWITCHTEC_PFX,
139 SWITCHTEC_PFXL,
140 SWITCHTEC_PFXI,
141 SWITCHTEC_PSX,
142 SWITCHTEC_PAX,
143 SWITCHTEC_PAXA,
144 SWITCHTEC_PFXA,
145 SWITCHTEC_PSXA,
146 SWITCHTEC_VAR_UNKNOWN,
147};
148
153 char name[256];
154 char desc[256];
155 char pci_dev[256];
156 char product_id[32];
157 char product_rev[8];
158 char fw_version[32];
159 char path[PATH_MAX];
160};
161
166 unsigned char partition;
168 unsigned char stack;
169 unsigned char upstream;
170 unsigned char stk_id;
171 unsigned char phys_id;
172 unsigned char log_id;
173};
174
183 unsigned char cfg_lnk_width;
184 unsigned char neg_lnk_width;
185 unsigned char link_up;
186 unsigned char link_rate;
187 uint16_t ltssm;
188 const char *ltssm_str;
189 unsigned char lane_reversal;
190 const char *lane_reversal_str;
191 unsigned char first_act_lane;
192 char lanes[17];
193
194 char *pci_bdf;
196
197 char *pci_dev;
201 unsigned int acs_ctrl;
202};
203
208 SWITCHTEC_BW_TYPE_RAW = 0x0,
209 SWITCHTEC_BW_TYPE_PAYLOAD = 0x1,
210};
211
217 SWITCHTEC_LOG_RAM,
218 SWITCHTEC_LOG_FLASH,
219 SWITCHTEC_LOG_FTDC,
220 SWITCHTEC_LOG_MEMLOG,
221 SWITCHTEC_LOG_REGS,
222 SWITCHTEC_LOG_SYS_STACK,
223 SWITCHTEC_LOG_THRD_STACK,
224 SWITCHTEC_LOG_THRD,
225 SWITCHTEC_LOG_NVHDR,
226};
227
232 SWITCHTEC_LOG_PARSE_TYPE_APP,
233 SWITCHTEC_LOG_PARSE_TYPE_MAILBOX,
234 SWITCHTEC_LOG_PARSE_TYPE_FTDC
235};
236
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;
246 bool overflow;
247 bool gen_unknown;
248 bool gen_ignored;
249};
250
255 SWITCHTEC_LOG_DEF_TYPE_APP,
256 SWITCHTEC_LOG_DEF_TYPE_MAILBOX
257};
258
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,
270};
271
272/* @brief
273* Gen6 FW read FW-types
274*
275* @note
276* These mrpc fw types are aligned to device fw types currently
277* but that is not required and may diverge in the future.
278* Intention is to keep the mrpc consistent over several generations
279* of devices even if device fw types change.
280*/
301
307 unsigned long part_id;
308 enum switchtec_fw_type type;
309 char version[32];
310 size_t part_addr;
311 size_t part_len;
313 size_t image_len;
314 unsigned long image_crc;
315
316 bool valid;
317 bool active;
318 bool running;
319 bool read_only;
320
321 struct switchtec_fw_image_info *next;
322 void *metadata;
323
324 unsigned long secure_version;
325 bool signed_image;
326 uint8_t redundant;
327};
328
331 struct switchtec_fw_image_info *active, *inactive;
332 } boot, map, img, cfg, nvlog, seeprom, key, bl2, riot, token;
333
334 struct switchtec_fw_image_info *mult_cfg;
335
336 int nr_info;
337 struct switchtec_fw_image_info all[];
338};
339
344 uint64_t global;
345 uint64_t part_bitmap;
346 unsigned local_part;
347
349 unsigned part[SWITCHTEC_MAX_PARTS];
350
352 unsigned pff[SWITCHTEC_MAX_PFF_CSR];
353};
354
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,
393};
394
395/*********** Platform Functions ***********/
396
397struct switchtec_dev *switchtec_open(const char *device);
398struct switchtec_dev *switchtec_open_by_path(const char *path);
399struct switchtec_dev *switchtec_open_by_index(int index);
400struct switchtec_dev *switchtec_open_by_pci_addr(int domain, int bus,
401 int device, int func);
402struct switchtec_dev *switchtec_open_i2c(const char *path, int i2c_addr);
403struct switchtec_dev *switchtec_open_i2c_by_adapter(int adapter, int i2c_addr);
404struct switchtec_dev *switchtec_open_uart(int fd);
405struct switchtec_dev *switchtec_open_eth(const char *ip, const int inst);
406
407void switchtec_close(struct switchtec_dev *dev);
408int switchtec_list(struct switchtec_device_info **devlist);
409void switchtec_list_free(struct switchtec_device_info *devlist);
410int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf,
411 size_t buflen);
412int switchtec_get_device_version(struct switchtec_dev *dev, int *res);
413int switchtec_cmd(struct switchtec_dev *dev, uint32_t cmd,
414 const void *payload, size_t payload_len, void *resp,
415 size_t resp_len);
416int switchtec_get_devices(struct switchtec_dev *dev,
417 struct switchtec_status *status,
418 int ports);
419int switchtec_pff_to_port(struct switchtec_dev *dev, int pff,
420 int *partition, int *port);
421int switchtec_port_to_pff(struct switchtec_dev *dev, int partition,
422 int port, int *pff);
423int switchtec_event_summary(struct switchtec_dev *dev,
424 struct switchtec_event_summary *sum);
425int switchtec_event_check(struct switchtec_dev *dev,
426 struct switchtec_event_summary *check,
427 struct switchtec_event_summary *res);
428int switchtec_event_ctl(struct switchtec_dev *dev,
429 enum switchtec_event_id e,
430 int index, int flags,
431 uint32_t data[5]);
432int switchtec_event_wait(struct switchtec_dev *dev, int timeout_ms);
433
434/*********** Generic Accessors ***********/
435
436_PURE const char *switchtec_name(struct switchtec_dev *dev);
437_PURE int switchtec_partition(struct switchtec_dev *dev);
438_PURE int switchtec_device_id(struct switchtec_dev *dev);
439_PURE enum switchtec_gen switchtec_gen(struct switchtec_dev *dev);
440_PURE enum switchtec_variant switchtec_variant(struct switchtec_dev *dev);
441_PURE enum switchtec_boot_phase
442switchtec_boot_phase(struct switchtec_dev *dev);
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);
445int switchtec_fw_img_get(struct switchtec_dev *dev, int fd,
446 enum switchtec_fw_type_gen6 fw_type, int fw_slot,
447 void (*progress_callback)(int cur, int tot));
448int switchtec_hard_reset(struct switchtec_dev *dev);
449int switchtec_status(struct switchtec_dev *dev,
450 struct switchtec_status **status);
451void switchtec_status_free(struct switchtec_status *status, int ports);
452int switchtec_get_device_info(struct switchtec_dev *dev,
453 enum switchtec_boot_phase *phase,
454 enum switchtec_gen *gen,
455 enum switchtec_rev *rev);
456const char *switchtec_strerror(void);
457void switchtec_perror(const char *str);
458int switchtec_log_to_file(struct switchtec_dev *dev,
459 enum switchtec_log_type type, int fd, FILE *log_def_file,
460 struct switchtec_log_file_info *info);
461int switchtec_parse_log(FILE *bin_log_file, FILE *log_def_file,
462 FILE *parsed_log_file,
463 enum switchtec_log_parse_type log_type,
464 enum switchtec_gen gen,
465 struct switchtec_log_file_info *info);
466int switchtec_log_def_to_file(struct switchtec_dev *dev,
467 enum switchtec_log_def_type type,
468 FILE* file);
469float switchtec_die_temp(struct switchtec_dev *dev);
470int switchtec_die_temps(struct switchtec_dev *dev, int nr_sensor,
471 float *sensor_readings);
472int switchtec_calc_lane_id(struct switchtec_dev *dev, int phys_port_id,
473 int lane_id, struct switchtec_status *port);
474int switchtec_calc_port_lane(struct switchtec_dev *dev, int lane_id,
475 int *phys_port_id, int *port_lane_id,
476 struct switchtec_status *port);
477int switchtec_calc_lane_mask(struct switchtec_dev *dev, int phys_port_id,
478 int lane_id, int num_lanes, int *lane_mask,
479 struct switchtec_status *port);
480
485
486int switchtec_inject_err_dllp(struct switchtec_dev *dev, int phys_port_id,
487 int data);
488int switchtec_inject_err_dllp_crc(struct switchtec_dev *dev, int phys_port_id,
489 int enable, uint16_t rate);
490int switchtec_inject_err_tlp_lcrc(struct switchtec_dev *dev, int phys_port_id,
491 int enable, uint8_t rate);
492int switchtec_inject_err_tlp_seq_num(struct switchtec_dev *dev, int phys_port_id);
493int switchtec_inject_err_ack_nack(struct switchtec_dev *dev, int phys_port_id,
494 uint16_t seq_num, uint8_t count);
495int switchtec_inject_err_cto(struct switchtec_dev *dev, int phys_port_id);
496
500static inline int switchtec_is_gen3(struct switchtec_dev *dev)
501{
502 return switchtec_gen(dev) == SWITCHTEC_GEN3;
503}
504
508static inline int switchtec_is_gen4(struct switchtec_dev *dev)
509{
510 return switchtec_gen(dev) == SWITCHTEC_GEN4;
511}
512
516static inline int switchtec_is_gen5(struct switchtec_dev *dev)
517{
518 return switchtec_gen(dev) == SWITCHTEC_GEN5;
519}
520
524static inline int switchtec_is_gen6(struct switchtec_dev *dev)
525{
526 return switchtec_gen(dev) == SWITCHTEC_GEN6;
527}
528
532static inline int switchtec_max_supported_ports(struct switchtec_dev *dev)
533{
534 switch(switchtec_gen(dev)) {
535 case SWITCHTEC_GEN6:
536 return SWITCHTEC_MAX_PORTS_GEN6;
537 case SWITCHTEC_GEN5:
538 return SWITCHTEC_MAX_PORTS;
539 case SWITCHTEC_GEN4:
540 return 52;
541 default:
542 return 48;
543 }
544}
545
549static inline int switchtec_is_pfx(struct switchtec_dev *dev)
550{
551 return switchtec_variant(dev) == SWITCHTEC_PFX;
552}
553
557static inline int switchtec_is_pfxl(struct switchtec_dev *dev)
558{
559 return switchtec_variant(dev) == SWITCHTEC_PFXL;
560}
561
565static inline int switchtec_is_pfxi(struct switchtec_dev *dev)
566{
567 return switchtec_variant(dev) == SWITCHTEC_PFXI;
568}
569
573static inline int switchtec_is_pfxa(struct switchtec_dev *dev)
574{
575 return switchtec_variant(dev) == SWITCHTEC_PFXA;
576}
577
581static inline int switchtec_is_pfx_all(struct switchtec_dev *dev)
582{
583 return switchtec_is_pfx(dev) ||
584 switchtec_is_pfxl(dev) ||
585 switchtec_is_pfxi(dev) ||
587}
588
592static inline int switchtec_is_psx(struct switchtec_dev *dev)
593{
594 return switchtec_variant(dev) == SWITCHTEC_PSX;
595}
596
600static inline int switchtec_is_psxa(struct switchtec_dev *dev)
601{
602 return switchtec_variant(dev) == SWITCHTEC_PSXA;
603}
604
608static inline int switchtec_is_psx_all(struct switchtec_dev *dev)
609{
610 return switchtec_is_psx(dev) ||
612}
613
617static inline int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
618{
619 return switchtec_is_psx_all(dev) || switchtec_is_pfx_all(dev);
620}
621
625static inline int switchtec_is_pax(struct switchtec_dev *dev)
626{
627 return switchtec_variant(dev) == SWITCHTEC_PAX;
628}
629
633static inline int switchtec_is_paxa(struct switchtec_dev *dev)
634{
635 return switchtec_variant(dev) == SWITCHTEC_PAXA;
636}
637
641static inline int switchtec_is_pax_all(struct switchtec_dev *dev)
642{
643 return switchtec_is_pax(dev) || switchtec_is_paxa(dev);
644}
645
649static inline const char *switchtec_gen_str(struct switchtec_dev *dev)
650{
651 const char *str;
652
653 str = switchtec_is_gen3(dev) ? "GEN3" :
654 switchtec_is_gen4(dev) ? "GEN4" :
655 switchtec_is_gen5(dev) ? "GEN5" :
656 switchtec_is_gen6(dev) ? "GEN6" : "Unknown";
657
658 return str;
659}
660
664static inline const char *switchtec_rev_str(enum switchtec_rev rev)
665{
666 const char *str;
667
668 str = (rev == SWITCHTEC_REVA) ? "REVA" :
669 (rev == SWITCHTEC_REVA1) ? "REVA.1" :
670 (rev == SWITCHTEC_REVB) ? "REVB" :
671 (rev == SWITCHTEC_REVC) ? "REVC" : "Unknown";
672
673 return str;
674}
675
679static inline const char *
681{
682 switch (inf->gen) {
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";
688 }
689}
690
694static inline const char *switchtec_variant_str(struct switchtec_dev *dev)
695{
696 const char *str;
697
698 str = switchtec_is_pfx(dev) ? "PFX" :
699 switchtec_is_pfxl(dev) ? "PFX-L" :
700 switchtec_is_pfxi(dev) ? "PFX-I" :
701 switchtec_is_psx(dev) ? "PSX" :
702 switchtec_is_pax(dev) ? "PAX" :
703 switchtec_is_pfxa(dev) ? "PFX-A" :
704 switchtec_is_psxa(dev) ? "PSX-A" :
705 switchtec_is_paxa(dev) ? "PAX-A" : "Unknown";
706
707 return str;
708}
709
713static inline const char* switchtec_phase_id_str(
714 enum switchtec_boot_phase phase_id)
715{
716 switch(phase_id) {
717 case SWITCHTEC_BOOT_PHASE_BL1:
718 return "BL1";
719 case SWITCHTEC_BOOT_PHASE_BL2:
720 return "BL2";
721 case SWITCHTEC_BOOT_PHASE_FW:
722 return "Main Firmware";
723 default:
724 return "Unknown Phase";
725 }
726}
727
729static const float switchtec_gen_transfers[] = {0, 2.5, 5, 8, 16, 32};
731static const float switchtec_gen_datarate[] = {0, 250, 500, 985, 1969, 3938};
732
733static inline const char *switchtec_ltssm_str_gen4(int ltssm, int show_minor)
734{
735 if (!show_minor)
736 ltssm |= 0xFF00;
737
738 switch(ltssm) {
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";
831 }
832
833}
834
835static inline const char *switchtec_ltssm_str_gen5(int ltssm, int show_minor)
836{
837 if (!show_minor)
838 ltssm |= 0xFF00;
839
840 switch(ltssm) {
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";
933 }
934}
935
936static inline const char *switchtec_ltssm_str_gen6(int ltssm_major)
937{
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";
976 }
977}
978
979static inline const char *switchtec_ltssm_str(int ltssm, int show_minor,
980 struct switchtec_dev *dev)
981{
982 if (switchtec_is_gen6(dev))
983 return switchtec_ltssm_str_gen6(ltssm);
984 else if (switchtec_is_gen5(dev))
985 return switchtec_ltssm_str_gen5(ltssm, show_minor);
986 else
987 return switchtec_ltssm_str_gen4(ltssm, show_minor);
988}
989
990/*********** EVENT Handling ***********/
991
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,
1006};
1007
1016 SWITCHTEC_EVT_IDX_LOCAL = -1,
1017 SWITCHTEC_EVT_IDX_ALL = -2,
1018};
1019
1025 SWITCHTEC_EVT_GLOBAL,
1026 SWITCHTEC_EVT_PART,
1027 SWITCHTEC_EVT_PFF,
1028};
1029
1031 enum switchtec_event_id e,
1032 int index);
1034 enum switchtec_event_id e,
1035 int index);
1036int switchtec_event_summary_iter(struct switchtec_dev *dev,
1037 struct switchtec_event_summary *sum,
1038 enum switchtec_event_id *e,
1039 int *idx);
1041 const char **name,
1042 const char **desc);
1043int switchtec_event_wait_for(struct switchtec_dev *dev,
1044 enum switchtec_event_id e, int index,
1045 struct switchtec_event_summary *res,
1046 int timeout_ms);
1047
1048/******** FIRMWARE Management ********/
1049
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,
1075
1076 SWITCHTEC_DLSTAT_ERROR_PROGRAM = 0x1000,
1077 SWITCHTEC_DLSTAT_ERROR_OFFSET = 0x1001,
1078
1079 SWITCHTEC_DLSTAT_NO_FILE = 0x7d009,
1080};
1081
1086 SWITCHTEC_FW_RW = 0,
1087 SWITCHTEC_FW_RO = 1,
1088};
1089
1090int switchtec_fw_set_redundant_flag(struct switchtec_dev *dev,
1091 int keyman, int riot,
1092 int bl2, int cfg, int fw,
1093 int set);
1094int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
1095 int toggle_bl2, int toggle_key,
1096 int toggle_fw, int toggle_cfg,
1097 int toggle_riotcore);
1098int switchtec_fw_write_fd(struct switchtec_dev *dev, int img_fd,
1099 int dont_activate, int force,
1100 void (*progress_callback)(int cur, int tot));
1101int switchtec_fw_write_file(struct switchtec_dev *dev, FILE *fimg,
1102 int dont_activate, int force,
1103 void (*progress_callback)(int cur, int tot));
1104int switchtec_fw_read_fd(struct switchtec_dev *dev, int fd,
1105 unsigned long addr, size_t len,
1106 void (*progress_callback)(int cur, int tot));
1107int switchtec_fw_body_read_fd(struct switchtec_dev *dev, int fd,
1108 struct switchtec_fw_image_info *info,
1109 void (*progress_callback)(int cur, int tot));
1110int switchtec_fw_read(struct switchtec_dev *dev, unsigned long addr,
1111 size_t len, void *buf);
1112void switchtec_fw_perror(const char *s, int ret);
1113int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info);
1114struct switchtec_fw_image_info *switchtec_fw_part_data_bl2(struct switchtec_dev *dev);
1116int switchtec_get_device_id_bl2(struct switchtec_dev *dev,
1117 unsigned short *device_id);
1118int switchtec_fw_file_secure_version_newer(struct switchtec_dev *dev,
1119 int img_fd);
1120const char *switchtec_fw_image_type(const struct switchtec_fw_image_info *info);
1122switchtec_fw_part_summary(struct switchtec_dev *dev);
1124int switchtec_sms_fmc_version_get(struct switchtec_dev *dev, uint32_t *info);
1125int switchtec_fw_img_write_hdr(int fd, struct switchtec_fw_image_info *info);
1126int switchtec_fw_is_boot_ro(struct switchtec_dev *dev);
1127int switchtec_fw_set_boot_ro(struct switchtec_dev *dev,
1128 enum switchtec_fw_ro ro);
1129enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version);
1130int switchtec_bind_info(struct switchtec_dev *dev,
1131 struct switchtec_bind_status_out *bind_status,
1132 int phy_port);
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);
1136bool switchtec_stack_bif_port_valid(struct switchtec_dev *dev, int stack_id,
1137 int port_id);
1138int switchtec_stack_bif_width(struct switchtec_dev *dev, int stack_id,
1139 int port_bif);
1140int switchtec_get_stack_bif(struct switchtec_dev *dev, int stack_id,
1141 int port_bif[SWITCHTEC_PORTS_PER_STACK]);
1142int switchtec_set_stack_bif(struct switchtec_dev *dev, int stack_id,
1143 int port_bif[SWITCHTEC_PORTS_PER_STACK]);
1144/********** RTC Counter **********/
1146 uint8_t sub_cmd;
1147 uint8_t reserved[3];
1148 uint64_t rtc_counter;
1149};
1150
1151enum RTC_OPERATION {
1152 MRPC_RTC_RESET,
1153 MRPC_RTC_SET,
1154 MRPC_RTC_GET,
1155};
1156
1157int switchtec_rtc_counter_reset(struct switchtec_dev *dev);
1158int switchtec_rtc_counter_set(struct switchtec_dev *dev, uint64_t *rtc_counter);
1159int switchtec_rtc_counter_get(struct switchtec_dev *dev, uint64_t *rtc_counter);
1160
1161/******** TWI ACCESS *************/
1162
1164 uint8_t sub_cmd;
1165 uint8_t twi_port;
1166 uint16_t slave_addr;
1167 uint32_t offset;
1168 uint16_t num_of_bytes;
1169 uint8_t slave_addr_size;
1170 uint8_t offset_size;
1171 uint32_t data[253];
1172};
1173
1175 uint8_t sub_cmd;
1176 uint8_t twi_port;
1177 uint8_t master_recov;
1178 uint8_t reserved;
1179 uint32_t duration_ms;
1180};
1181
1182enum TWI_ACCESS_OP {
1183 TWI_ACCESS_READ = 0,
1184 TWI_ACCESS_WRITE,
1185 TWI_ACCESS_RESET,
1186};
1187
1188int switchtec_twi_access_write(struct switchtec_dev *dev, uint8_t twi_port,
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);
1192int switchtec_twi_access_read(struct switchtec_dev *dev, uint8_t twi_port,
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);
1196int switchtec_twi_access_reset(struct switchtec_dev *dev, uint8_t master_recov,
1197 uint8_t twi_port, uint32_t duration_ms);
1198
1199/******** GPIO Management ********/
1200
1202 uint8_t sub_cmd;
1203 uint8_t resvd;
1204 uint16_t log_gpio_id;
1205 uint8_t data;
1206 uint8_t resvd1[3];
1207};
1208
1210 uint8_t sub_cmd;
1211 uint8_t resvd;
1212 uint16_t pin_num;
1213 uint32_t pin_values[SWITCHTEC_MAX_GPIO_PIN_VALS];
1214};
1215
1216int switchtec_get_gpio(struct switchtec_dev *dev, int pin_id,
1217 int *gpio_val);
1218int switchtec_set_gpio(struct switchtec_dev *dev, int pin_id,
1219 int gpio_val);
1220int switchtec_get_gpio_direction_cfg(struct switchtec_dev *dev, int pin_id,
1221 int *direction);
1222int switchtec_get_gpio_polarity_cfg(struct switchtec_dev *dev, int pin_id,
1223 int *polarity);
1224int switchtec_en_dis_interrupt(struct switchtec_dev *dev, int pin_id, int en);
1225int switchtec_get_all_pin_sts(struct switchtec_dev *dev, uint32_t *values);
1226
1227/********** EVENT COUNTER *********/
1228
1277
1282extern const struct switchtec_evcntr_type_list {
1284 const char *name;
1285 const char *help;
1287
1292 unsigned port_mask; //<! Mask of ports this counter counts
1293
1296 int egress; //<! If 1, count egress, otherwise on ingress
1297
1302 unsigned threshold;
1303};
1304
1306const char *switchtec_evcntr_type_str(int *type_mask);
1307int switchtec_evcntr_setup(struct switchtec_dev *dev, unsigned stack_id,
1308 unsigned cntr_id,
1309 struct switchtec_evcntr_setup *setup);
1310int switchtec_evcntr_get_setup(struct switchtec_dev *dev, unsigned stack_id,
1311 unsigned cntr_id, unsigned nr_cntrs,
1312 struct switchtec_evcntr_setup *res);
1313int switchtec_evcntr_get(struct switchtec_dev *dev, unsigned stack_id,
1314 unsigned cntr_id, unsigned nr_cntrs, unsigned *res,
1315 int clear);
1316int switchtec_evcntr_get_both(struct switchtec_dev *dev, unsigned stack_id,
1317 unsigned cntr_id, unsigned nr_cntrs,
1318 struct switchtec_evcntr_setup *setup,
1319 unsigned *counts, int clear);
1320int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms);
1321
1322/********** BANDWIDTH COUNTER *********/
1323
1336
1337void switchtec_bwcntr_sub(struct switchtec_bwcntr_res *new_cntr,
1338 struct switchtec_bwcntr_res *old_cntr);
1339int switchtec_bwcntr_set_many(struct switchtec_dev *dev, int nr_ports,
1340 int * phys_port_ids,
1341 enum switchtec_bw_type bw_type);
1342int switchtec_bwcntr_set_all(struct switchtec_dev *dev,
1343 enum switchtec_bw_type bw_type);
1344int switchtec_bwcntr_many(struct switchtec_dev *dev, int nr_ports,
1345 int *phys_port_ids, int clear,
1346 struct switchtec_bwcntr_res *res);
1347int switchtec_bwcntr_all(struct switchtec_dev *dev, int clear,
1348 struct switchtec_port_id **ports,
1349 struct switchtec_bwcntr_res **res);
1350uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d);
1351
1352/********** LATENCY COUNTER *********/
1353
1354#define SWITCHTEC_LAT_ALL_INGRESS 63
1355
1356int switchtec_lat_setup_many(struct switchtec_dev *dev, int nr_ports,
1357 int *egress_port_ids, int *ingress_port_ids);
1358int switchtec_lat_setup(struct switchtec_dev *dev, int egress_port_id,
1359 int ingress_port_id, int clear);
1360int switchtec_lat_get_many(struct switchtec_dev *dev, int nr_ports,
1361 int clear, int *egress_port_ids,
1362 int *cur_ns, int *max_ns);
1363int switchtec_lat_get(struct switchtec_dev *dev, int clear,
1364 int egress_port_ids, int *cur_ns,
1365 int *max_ns);
1366
1367/********** GLOBAL ADDRESS SPACE ACCESS *********/
1368
1369/*
1370 * GAS map maps the hardware registers into user memory space.
1371 * Needless to say, this can be very dangerous and should only
1372 * be done if you know what you are doing. Any register accesses
1373 * that use this will remain unsupported by Microsemi unless it's
1374 * done within the switchtec user project or otherwise specified.
1375 */
1376
1377gasptr_t switchtec_gas_map(struct switchtec_dev *dev, int writeable,
1378 size_t *map_size);
1379void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map);
1380
1381/********** DIAGNOSTIC FUNCTIONS *********/
1382
1383#define SWITCHTEC_DIAG_CROSS_HAIR_ALL_LANES -1
1384#define SWITCHTEC_DIAG_CROSS_HAIR_MAX_LANES 64
1385
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,
1410};
1411
1413 enum switchtec_diag_cross_hair_state state;
1414 int lane_id;
1415
1416 union {
1417 struct {
1418 /* Valid when state is Error */
1419 int prev_state;
1420 int x_pos;
1421 int y_pos;
1422 };
1423 /* Valid when state is DONE */
1424 struct {
1425 int eye_left_lim;
1426 int eye_right_lim;
1427 int eye_bot_left_lim;
1428 int eye_bot_right_lim;
1429 int eye_top_left_lim;
1430 int eye_top_right_lim;
1431 };
1432 };
1433};
1434
1436 int port_id;
1437 int lane_id;
1438 int ctle;
1439 int target_amplitude;
1440 int speculative_dfe;
1441 int dynamic_dfe[7];
1442};
1443
1445 uint8_t lane_cnt;
1446 uint8_t reserved[3];
1447 struct {
1448 uint8_t pre;
1449 uint8_t post;
1450 } cursors[16];
1451};
1452
1454 uint8_t lane_cnt;
1455 uint8_t reserved[3];
1456 struct {
1457 uint8_t is_coef;
1458 uint8_t pre;
1459 uint8_t post;
1460 uint8_t preset;
1461 } cursors[16];
1462};
1463
1469
1480
1482 uint8_t cmd;
1483 uint8_t op_type;
1484 uint8_t phys_port_id;
1485 uint8_t lane_id;
1486 uint8_t dump_type;
1487 uint8_t prev_rate;
1488 uint8_t reserved[2];
1489};
1490
1492 uint8_t sub_cmd;
1493 uint8_t port_id;
1494 uint8_t dump_type;
1495 uint8_t prev_rate;
1496};
1497
1499 int lane_id;
1500 int step_cnt;
1501
1502 struct {
1503 int pre_cursor;
1504 int post_cursor;
1505 int fom;
1506 int pre_cursor_up;
1507 int post_cursor_up;
1508 int error_status;
1509 int active_status;
1510 int speed;
1511 } steps[126];
1512};
1513
1515 uint8_t lane_id;
1516 uint8_t step_cnt;
1517 uint8_t reserved[2];
1518
1519 struct {
1520 uint8_t pre_cursor;
1521 uint8_t post_cursor;
1522 uint16_t reserved_0;
1523 uint8_t reserved_1;
1524 uint8_t error_status;
1525 uint8_t active_status;
1526 uint8_t speed;
1527 } steps[25];
1528};
1529
1531 int fs;
1532 int lf;
1533};
1534
1536 uint8_t fs;
1537 uint8_t lf;
1538 uint8_t reserved[2];
1539};
1540
1542 uint8_t sub_cmd;
1543 uint8_t port_id;
1544 uint8_t lane_id;
1545 uint8_t dump_type;
1546 uint8_t prev_rate;
1547 uint8_t reserved[3];
1548};
1549
1551 int ctle2_rx_mode;
1552 int dtclk_5;
1553 int dtclk_8_6;
1554 int dtclk_9;
1555};
1556
1558 const char *tag;
1559 const char *desc;
1560 bool reserved;
1561};
1562
1563enum switchtec_diag_eye_data_mode {
1564 SWITCHTEC_DIAG_EYE_RAW,
1565 SWITCHTEC_DIAG_EYE_RATIO,
1566};
1567
1568enum switchtec_diag_eye_data_mode_gen6 {
1569 SWITCHTEC_DIAG_EYE_ADC,
1570 SWITCHTEC_DIAG_EYE_FFE,
1571 SWITCHTEC_DIAG_EYE_DFE,
1572};
1573
1574enum switchtec_diag_eye_mode_gen6 {
1575 SWITCHTEC_DIAG_EYE_FULL,
1576 SWITCHTEC_DIAG_EYE_INTERLEAVE,
1577 SWITCHTEC_DIAG_EYE_SAR,
1578};
1579
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,
1585};
1586
1588 uint8_t sub_cmd;
1589 uint8_t resvd1[3];
1590};
1591
1593 uint8_t status;
1594 uint8_t resvd1[3];
1595};
1596
1598 uint8_t sub_cmd;
1599 uint8_t lane_id;
1600 uint8_t bin;
1601 uint8_t resvd1;
1602};
1603
1605 uint8_t num_phases;
1606 uint8_t resvd1[3];
1607 uint32_t resvd2;
1608 uint64_t ber_data[60];
1609};
1610
1612 uint8_t sub_cmd;
1613 uint8_t lane_id;
1614 uint16_t bin_num;
1615};
1616
1618 uint8_t num_phases;
1619 uint8_t resvd1[3];
1620 uint32_t resvd2;
1621 uint32_t ndes_data[64];
1622};
1623
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,
1629};
1630
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,
1639};
1640
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,
1653};
1654
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,
1667};
1668
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,
1677};
1678
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,
1686};
1687
1688enum switchtec_diag_end {
1689 SWITCHTEC_DIAG_LOCAL,
1690 SWITCHTEC_DIAG_FAR_END,
1691};
1692
1693enum switchtec_diag_link {
1694 SWITCHTEC_DIAG_LINK_CURRENT,
1695 SWITCHTEC_DIAG_LINK_PREVIOUS,
1696};
1697
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,
1705};
1706
1708 unsigned int timestamp;
1709 float link_rate;
1710 int link_state;
1711 /* Gen 6 stucture variables */
1712 int link_width;
1713 int tx_minor_state;
1714 int rx_minor_state;
1715};
1716
1721 uint8_t state;
1722 uint8_t trigger_lane;
1723 uint8_t trigger_dir;
1724 uint16_t trigger_reason;
1725};
1726
1731 /* OS Type Trigger */
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;
1736
1737 /* OS Pattern Trigger */
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];
1743
1744 /* Misc Trigger */
1745 uint8_t misc_trig_enable;
1746
1747 /* Capture Config */
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;
1755};
1756
1761 uint64_t timestamp;
1762 uint8_t link_rate;
1763 uint32_t counter;
1764 uint8_t trigger_indication;
1765 uint8_t os_dropped;
1766 uint32_t osa_data[4];
1767};
1768
1772#define SWITCHTEC_OSA_MAX_ENTRIES 1024
1774 uint8_t stack_id;
1775 uint8_t lane;
1776 uint8_t direction;
1777 uint16_t total_entries;
1778 uint8_t wrap_occurred;
1779 uint16_t entry_count;
1781};
1782
1783int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id);
1784int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev);
1785int switchtec_diag_cross_hair_get(struct switchtec_dev *dev, int start_lane_id,
1786 int num_lanes, struct switchtec_diag_cross_hair *res);
1787
1788int switchtec_diag_eye_set_mode(struct switchtec_dev *dev,
1789 enum switchtec_diag_eye_data_mode mode);
1790int switchtec_diag_eye_read(struct switchtec_dev *dev, int lane_id, int bin,
1791 int* num_phases, double* ber_data);
1792int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4],
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);
1797int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels,
1798 size_t pixel_cnt, int *lane_id);
1799int switchtec_diag_eye_cancel(struct switchtec_dev *dev);
1800
1801int switchtec_diag_loopback_set(struct switchtec_dev *dev, int port_id,
1802 int enable, int enable_parallel,
1803 int enable_external, int enable_ltssm,
1804 int enable_pipe,
1805 enum switchtec_diag_ltssm_speed ltssm_speed);
1806int switchtec_diag_loopback_get(struct switchtec_dev *dev, int port_id,
1807 int *enabled,
1808 enum switchtec_diag_ltssm_speed *ltssm_speed);
1809int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
1810 enum switchtec_diag_pattern type,
1811 enum switchtec_diag_pattern_link_rate
1812 link_speed);
1813int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
1814 enum switchtec_diag_pattern *type);
1815int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,
1816 enum switchtec_diag_pattern type);
1817int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id,
1818 int lane_id,
1819 enum switchtec_diag_pattern *type,
1820 unsigned long long *err_cnt);
1821int switchtec_diag_pattern_inject(struct switchtec_dev *dev, int port_id,
1822 unsigned int err_cnt);
1823
1824int switchtec_diag_rcvr_obj(struct switchtec_dev *dev, int port_id,
1825 int lane_id, enum switchtec_diag_link link,
1826 struct switchtec_rcvr_obj *res);
1827int switchtec_diag_rcvr_ext(struct switchtec_dev *dev, int port_id,
1828 int lane_id, enum switchtec_diag_link link,
1829 struct switchtec_rcvr_ext *res);
1830
1831int switchtec_diag_port_eq_tx_coeff(struct switchtec_dev *dev, int port_id,
1832 int prev_speed, enum switchtec_diag_end end,
1833 enum switchtec_diag_link link,
1834 struct switchtec_port_eq_coeff *res);
1835int switchtec_diag_port_eq_tx_table(struct switchtec_dev *dev, int port_id,
1836 int prev_speed,
1837 enum switchtec_diag_link link,
1838 struct switchtec_port_eq_table *res);
1839int switchtec_diag_port_eq_tx_fslf(struct switchtec_dev *dev, int port_id,
1840 int prev_speed, int lane_id,
1841 enum switchtec_diag_end end,
1842 enum switchtec_diag_link link,
1843 struct switchtec_port_eq_tx_fslf *res);
1844
1845int switchtec_diag_perm_table(struct switchtec_dev *dev,
1846 struct switchtec_mrpc table[MRPC_MAX_ID]);
1847int switchtec_diag_refclk_ctl(struct switchtec_dev *dev, int id, bool en);
1848int switchtec_diag_refclk_status(struct switchtec_dev *dev, uint8_t *info);
1849int switchtec_diag_ltssm_clear(struct switchtec_dev *dev, int port);
1850int switchtec_diag_ltssm_log(struct switchtec_dev *dev,
1851 int port, int *log_count,
1852 struct switchtec_diag_ltssm_log *log_data);
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);
1855int switchtec_aer_event_gen(struct switchtec_dev *dev, int port_id,
1856 int aer_error_id, int trigger_event);
1857int switchtec_osa(struct switchtec_dev * dev, int stack_id, int operation,
1858 struct switchtec_osa_status *status);
1859int switchtec_osa_config_type(struct switchtec_dev * dev, int stack_id,
1860 int direction, int lane_mask, int link_rate,
1861 int os_types);
1862int switchtec_osa_config_misc(struct switchtec_dev * dev, int stack_id,
1863 int trigger_en);
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,
1868 int os_types);
1869int switchtec_osa_dump_conf(struct switchtec_dev * dev, int stack_id,
1870 struct switchtec_osa_config *config);
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);
1874int switchtec_osa_capture_data(struct switchtec_dev * dev, int stack_id,
1875 int lane, int direction,
1876 struct switchtec_osa_capture_data *data);
1877#ifdef __cplusplus
1878}
1879#endif
1880
1881#endif
struct switchtec_dev * switchtec_open(const char *device)
Open a Switchtec device by string.
Definition switchtec.c:279
void switchtec_list_free(struct switchtec_device_info *devlist)
Free a list of device info structures allocated by switchtec_list().
Definition switchtec.c:257
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.
Definition platform.c:178
void switchtec_close(struct switchtec_dev *dev)
Close a Switchtec device handle.
Definition platform.c:101
void switchtec_perror(const char *str)
Print an error string to stdout.
Definition switchtec.c:871
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().
Definition switchtec.c:709
int switchtec_status(struct switchtec_dev *dev, struct switchtec_status **status)
Get the status of all the ports on a switchtec device.
Definition switchtec.c:694
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.
Definition switchtec.c:412
const char * switchtec_strerror(void)
Return a message coresponding to the last error.
Definition switchtec.c:748
_PURE int switchtec_device_id(struct switchtec_dev *dev)
Get the device id of the device.
Definition switchtec.c:364
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...
Definition platform.c:209
int switchtec_get_device_version(struct switchtec_dev *dev, int *res)
Get the minor version number as a user readable int.
Definition platform.c:159
_PURE int switchtec_partition(struct switchtec_dev *dev)
Get the partiton number of the device that was opened.
Definition switchtec.c:422
int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf, size_t buflen)
Get the firmware version as a user readable string.
Definition platform.c:125
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.
Definition platform.c:328
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...
Definition events.c:348
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.
Definition events.c:374
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.
Definition events.c:249
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.
Definition events.c:176
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.
Definition platform.c:312
int switchtec_event_wait(struct switchtec_dev *dev, int timeout_ms)
Wait for any event to occur (typically just an interrupt).
Definition platform.c:344
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.
Definition events.c:220
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.
Definition events.c:302
enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version)
Extract generation information from FW version number.
Definition fw.c:623
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.
Definition fw.c:367
int switchtec_fw_img_write_hdr(int fd, struct switchtec_fw_image_info *info)
Write the header for a Switchtec firmware image file.
Definition fw.c:2356
int switchtec_fw_read(struct switchtec_dev *dev, unsigned long addr, size_t len, void *buf)
Read a Switchtec device's flash data.
Definition fw.c:2204
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.
Definition fw.c:2297
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.
Definition fw.c:1094
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.
Definition fw.c:2248
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.
Definition fw.c:1820
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.
Definition fw.c:2044
int switchtec_fw_is_boot_ro(struct switchtec_dev *dev)
Check if the boot partition is marked as read-only.
Definition fw.c:2382
int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info)
Retrieve information about a firmware image file.
Definition fw.c:1059
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.
Definition fw.c:531
void switchtec_fw_perror(const char *s, int ret)
Print an error string to stdout.
Definition fw.c:750
void switchtec_fw_image_info_free(struct switchtec_fw_image_info *inf)
Free a firmware image info data structure.
Definition fw.c:2179
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.
Definition fw.c:2421
void switchtec_fw_part_summary_free(struct switchtec_fw_part_summary *summary)
Free a firmware part summary data structure.
Definition fw.c:2165
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.
Definition fw.c:334
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.
Definition fw.c:454
const char * switchtec_fw_image_type(const struct switchtec_fw_image_info *info)
Return a string describing the type of a firmware image.
Definition fw.c:1146
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.
Definition fw.c:654
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.
Definition platform.c:270
void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map)
Unmap the GAS region mapped with.
Definition platform.c:282
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.
Definition switchtec.c:2327
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.
Definition switchtec.c:2264
int switchtec_get_gpio(struct switchtec_dev *dev, int pin_id, int *gpio_val)
Get the GPIO pin value.
Definition switchtec.c:2430
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.
Definition switchtec.c:1640
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.
Definition switchtec.c:2724
int switchtec_set_gpio(struct switchtec_dev *dev, int pin_id, int gpio_val)
Set the GPIO pin value.
Definition switchtec.c:2456
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.
Definition platform.c:243
int switchtec_get_gpio_polarity_cfg(struct switchtec_dev *dev, int pin_id, int *polarity)
Get the GPIO pin polarity.
Definition switchtec.c:2501
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.
Definition switchtec.c:1723
float switchtec_die_temp(struct switchtec_dev *dev)
Get the die temperature of the switchtec device.
Definition switchtec.c:1984
int switchtec_die_temps(struct switchtec_dev *dev, int nr_sensor, float *sensor_readings)
Get the die temperature sensor readings of the switchtec device.
Definition switchtec.c:2028
int switchtec_rtc_counter_set(struct switchtec_dev *dev, uint64_t *rtc_counter)
Set the RTC counter.
Definition switchtec.c:2588
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.
Definition switchtec.c:2352
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.
Definition switchtec.c:2637
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.
Definition switchtec.c:2311
int switchtec_hard_reset(struct switchtec_dev *dev)
Perform an MRPC hard reset command.
Definition switchtec.c:918
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.
Definition platform.c:228
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.
Definition switchtec.c:1848
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.
Definition switchtec.c:1929
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.
Definition switchtec.c:2683
int switchtec_en_dis_interrupt(struct switchtec_dev *dev, int pin_id, int en)
Enable/Disable the GPIO pin interrupt.
Definition switchtec.c:2527
int switchtec_rtc_counter_reset(struct switchtec_dev *dev)
Perform a reset operation on the RTC counter.
Definition switchtec.c:2568
int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output)
Perform an MRPC echo command.
Definition switchtec.c:902
int switchtec_get_all_pin_sts(struct switchtec_dev *dev, uint32_t *values)
Get all GPIO pin status.
Definition switchtec.c:2546
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.
Definition switchtec.c:2396
int switchtec_rtc_counter_get(struct switchtec_dev *dev, uint64_t *rtc_counter)
Get the RTC counter.
Definition switchtec.c:2609
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.
Definition switchtec.c:2160
int switchtec_get_gpio_direction_cfg(struct switchtec_dev *dev, int pin_id, int *direction)
Get the GPIO pin direction.
Definition switchtec.c:2475
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.
Definition switchtec.c:2200
const char * switchtec_evcntr_type_str(int *type_mask)
Get a string for the event indicated by lowest bit set in the type_mask.
Definition pmon.c:116
int switchtec_evcntr_type_count(void)
Get the number of event counter types.
Definition pmon.c:95
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.
Definition pmon.c:633
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.
Definition pmon.c:339
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.
Definition pmon.c:139
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.
Definition pmon.c:387
int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms)
Block until any event counter has reached its threshold.
Definition pmon.c:325
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.
Definition pmon.c:301
int switchtec_lat_setup(struct switchtec_dev *dev, int egress_port_id, int ingress_port_id, int clear)
Setup a latency counter.
Definition pmon.c:557
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.
Definition pmon.c:419
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.
Definition pmon.c:473
uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d)
Get the total.
Definition pmon.c:513
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.
Definition pmon.c:585
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.
Definition pmon.c:527
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.
Definition pmon.c:257
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.
Definition pmon.c:359
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.
Definition pmon.c:214
Definition utils.h:34
uint64_t comp
Completion TLP bytes.
Definition switchtec.h:1331
uint64_t nonposted
Non-Posted TLP bytes.
Definition switchtec.h:1332
Bandwidth counter result struct.
Definition switchtec.h:1327
struct switchtec_bwcntr_res::switchtec_bwcntr_dir ingress
Bandwidth into the port.
uint64_t time_us
Time (in microseconds).
Definition switchtec.h:1328
struct switchtec_bwcntr_res::switchtec_bwcntr_dir egress
Bandwidth out of the port.
Represents a Switchtec device in the switchtec_list() function.
Definition switchtec.h:152
char fw_version[32]
Firmware version.
Definition switchtec.h:158
char pci_dev[256]
PCI BDF string.
Definition switchtec.h:155
char desc[256]
Device description, if available.
Definition switchtec.h:154
char path[PATH_MAX]
Path to the device.
Definition switchtec.h:159
char name[256]
Device name, eg. switchtec0.
Definition switchtec.h:153
char product_id[32]
Product ID.
Definition switchtec.h:156
char product_rev[8]
Product revision.
Definition switchtec.h:157
Structure used to setup an event counter.
Definition switchtec.h:1291
unsigned threshold
Threshold to count to before generating an interrupt.
Definition switchtec.h:1302
enum switchtec_evcntr_type_mask type_mask
Event counter types to count.
Definition switchtec.h:1295
Null-terminated list of all event counter types with a name and help text.
Definition switchtec.h:1282
Event summary bitmaps.
Definition switchtec.h:343
uint64_t part_bitmap
Bitmap of partitions with active events.
Definition switchtec.h:345
uint64_t global
Bitmap of global events.
Definition switchtec.h:344
unsigned part[SWITCHTEC_MAX_PARTS]
Bitmap of events in each partition.
Definition switchtec.h:349
unsigned local_part
Bitmap of events in the local partition.
Definition switchtec.h:346
unsigned pff[SWITCHTEC_MAX_PFF_CSR]
Bitmap of events in each port function.
Definition switchtec.h:352
Information about a firmware image or partition.
Definition switchtec.h:305
enum switchtec_gen gen
Image generation.
Definition switchtec.h:306
size_t part_body_offset
Partition image body offset.
Definition switchtec.h:312
unsigned long image_crc
CRC checksum of the image.
Definition switchtec.h:314
char version[32]
Firmware/Config version.
Definition switchtec.h:309
size_t image_len
Length of the image.
Definition switchtec.h:313
unsigned long part_id
Image partition ID.
Definition switchtec.h:307
size_t part_addr
Address of the partition.
Definition switchtec.h:310
size_t part_len
Length of the partition.
Definition switchtec.h:311
enum switchtec_fw_type type
Image partition type.
Definition switchtec.h:308
Information about log file and log definition file.
Definition switchtec.h:240
OSA capture data entry.
Definition switchtec.h:1760
OSA configuration dump result.
Definition switchtec.h:1730
OSA status query result.
Definition switchtec.h:1720
Port identification.
Definition switchtec.h:165
unsigned char upstream
1 if this is an upstream port
Definition switchtec.h:169
unsigned char partition
Partition the port is in.
Definition switchtec.h:166
unsigned char stk_id
Port number within the stack.
Definition switchtec.h:170
unsigned char log_id
Logical port number.
Definition switchtec.h:172
unsigned char phys_id
Physical port number.
Definition switchtec.h:171
unsigned char stack
Stack number.
Definition switchtec.h:168
Port status structure.
Definition switchtec.h:181
struct switchtec_port_id port
Port ID.
Definition switchtec.h:182
unsigned char link_up
1 if the link is up
Definition switchtec.h:185
unsigned char lane_reversal
Lane reversal.
Definition switchtec.h:189
unsigned int acs_ctrl
ACS Setting of the Port.
Definition switchtec.h:201
const char * lane_reversal_str
Lane reversal as a string.
Definition switchtec.h:190
unsigned char cfg_lnk_width
Configured link width.
Definition switchtec.h:183
unsigned char link_rate
Link rate/gen.
Definition switchtec.h:186
unsigned char first_act_lane
First active lane.
Definition switchtec.h:191
int vendor_id
Vendor ID.
Definition switchtec.h:198
unsigned char neg_lnk_width
Negotiated link width.
Definition switchtec.h:184
uint16_t ltssm
Link state.
Definition switchtec.h:187
char * pci_bdf_path
PCI BDF path of the port.
Definition switchtec.h:195
char * pci_bdf
PCI BDF of the port.
Definition switchtec.h:194
int device_id
Device ID.
Definition switchtec.h:199
char * class_devices
Comma seperated list of classes.
Definition switchtec.h:200
char * pci_dev
PCI BDF of the device on the port.
Definition switchtec.h:197
const char * ltssm_str
Link state as a string.
Definition switchtec.h:188
switchtec_bw_type
The types of bandwidth.
Definition switchtec.h:207
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.
Definition diag.c:1540
lane_eq_dump_type_enum
Definition switchtec.h:1464
@ LANE_EQ_DUMP_TYPE_NUM
Total number of dump types.
Definition switchtec.h:1467
@ LANE_EQ_DUMP_TYPE_PREV
Previous link-up settings.
Definition switchtec.h:1466
@ LANE_EQ_DUMP_TYPE_CURR
Current settings.
Definition switchtec.h:1465
static int switchtec_is_pfxl(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-L.
Definition switchtec.h:557
switchtec_log_parse_type
Log types to parse.
Definition switchtec.h:231
int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev)
Disable active cross hair.
Definition diag.c:70
switchtec_event_id
Enumeration of all possible events.
Definition switchtec.h:358
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.
Definition diag.c:770
int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern *type)
Get Pattern Generator set on port.
Definition diag.c:716
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.
Definition diag.c:1300
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.
Definition diag.c:1504
static int switchtec_is_psxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX-A.
Definition switchtec.h:600
int switchtec_diag_loopback_get(struct switchtec_dev *dev, int port_id, int *enabled, enum switchtec_diag_ltssm_speed *ltssm_speed)
Setup Loopback Mode.
Definition diag.c:623
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.
Definition diag.c:2245
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.
Definition diag.c:248
switchtec_fw_ro
Flag which indicates if a partition is read-only or not.
Definition switchtec.h:1085
switchtec_rev
Device hardware revision.
Definition switchtec.h:105
int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels, size_t pixel_cnt, int *lane_id)
Start a PCIe Eye Capture.
Definition diag.c:403
static int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX or PSX.
Definition switchtec.h:617
switchtec_evcntr_type_mask
Event counter type mask (may be or-d together).
Definition switchtec.h:1232
@ ALL_TLPS
Mask indicating all TLP types.
Definition switchtec.h:1270
@ RCVR_ERR
Receiver Error.
Definition switchtec.h:1247
@ RCVR_OFLOW_ERR
Receiver Overflow Error.
Definition switchtec.h:1236
@ REPLAY_NUM_ROLLOVER
Replay Number Rollover.
Definition switchtec.h:1244
@ COMP_TLP
Completion TLP.
Definition switchtec.h:1254
@ BAD_TLP
Bad TLP.
Definition switchtec.h:1246
@ NON_POSTED_TLP
Non-Posted TLP.
Definition switchtec.h:1255
@ BAD_DLLP
Bad DLLP.
Definition switchtec.h:1245
@ SURPRISE_DOWN_ERR
Surprise Down Error.
Definition switchtec.h:1239
@ POISONED_TLP_ERR
Poisoned TLP Error.
Definition switchtec.h:1238
@ ALL_ERRORS
Mask indicating all possible errors.
Definition switchtec.h:1260
@ RCV_CORR_MSG
Receive Correctable Error Message.
Definition switchtec.h:1250
@ RCV_NON_FATAL_MSG
Receive Non-FATAL Error Message.
Definition switchtec.h:1249
@ NAK_RCVD
NAK Received.
Definition switchtec.h:1251
@ UNSUP_REQ_ERR
Unsupported Request Error.
Definition switchtec.h:1233
@ POSTED_TLP
Posted TLP.
Definition switchtec.h:1253
@ RULE_TABLE_HIT
Rule Search Table Rule Hit.
Definition switchtec.h:1252
@ ALL
Mask indicating all event types.
Definition switchtec.h:1275
@ ECRC_ERR
ECRC Error.
Definition switchtec.h:1234
@ REPLAY_TMR_TIMEOUT
Replay Timer Timeout.
Definition switchtec.h:1243
@ HDR_LOG_OFLOW_ERR
Header Log Overflow Error.
Definition switchtec.h:1241
@ DATA_LINK_PROTO_ERR
Data Link Protocol Error.
Definition switchtec.h:1240
@ UNCOR_INT_ERR
Uncorrectable Internal Error.
Definition switchtec.h:1242
@ CMPLTR_ABORT_ERR
Completer Abort Error.
Definition switchtec.h:1237
@ RCV_FATAL_MSG
Receive FATAL Error Message.
Definition switchtec.h:1248
@ MALFORM_TLP_ERR
Malformed TLP Error.
Definition switchtec.h:1235
int switchtec_diag_pattern_inject(struct switchtec_dev *dev, int port_id, unsigned int err_cnt)
Inject error into pattern generator.
Definition diag.c:811
static const char * switchtec_rev_str(enum switchtec_rev rev)
Return the revision string.
Definition switchtec.h:664
static const char * switchtec_gen_str(struct switchtec_dev *dev)
Return the generation string of a Switchtec device.
Definition switchtec.h:649
static int switchtec_is_pfxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-A.
Definition switchtec.h:573
static int switchtec_is_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX(L/I/A).
Definition switchtec.h:581
static int switchtec_is_pfxi(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-I.
Definition switchtec.h:565
switchtec_gen
The PCIe generations.
Definition switchtec.h:94
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.
Definition diag.c:838
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.
Definition diag.c:309
link_rate_enum
Definition switchtec.h:1470
@ PCIE_LINK_RATE_GEN3
Gen3, supports 2.5GT/s, 5GT/s, 8GT/s.
Definition switchtec.h:1474
@ PCIE_LINK_RATE_GEN1
Gen1, supports 2.5GT/s.
Definition switchtec.h:1472
@ PCIE_LINK_RATE_GEN4
Gen4, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s.
Definition switchtec.h:1475
@ PCIE_LINK_RATE_NUM
Total number of PCIe generations.
Definition switchtec.h:1478
@ PCIE_LINK_RATE_GEN5
Gen5, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s, 32GT/s.
Definition switchtec.h:1476
@ PCIE_LINK_RATE_GEN6
Gen6, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s, 32GT/s, 64GT/s.
Definition switchtec.h:1477
@ PCIE_LINK_RATE_GEN2
Gen2, supports 2.5GT/s, 5GT/s.
Definition switchtec.h:1473
@ PCIE_LINK_RATE_INV
Invalid.
Definition switchtec.h:1471
static int switchtec_is_psx(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX.
Definition switchtec.h:592
int switchtec_diag_perm_table(struct switchtec_dev *dev, struct switchtec_mrpc table[MRPC_MAX_ID])
Get the permission table.
Definition diag.c:1585
switchtec_fw_type_gen6
Definition switchtec.h:281
@ SWITCHTEC_IMG_PART_TYPE_CERT
Definition switchtec.h:288
@ SWITCHTEC_IMG_PART_TYPE_RSVD_13
Definition switchtec.h:295
@ SWITCHTEC_IMG_PART_TYPE_FW
Definition switchtec.h:286
@ SWITCHTEC_IMG_PART_TYPE_RSVD_9
Definition switchtec.h:291
@ SWITCHTEC_IMG_PART_TYPE_RSVD_14
Definition switchtec.h:296
@ SWITCHTEC_IMG_PART_TYPE_DEBUG_TOKEN
Definition switchtec.h:289
@ SWITCHTEC_IMG_PART_TYPE_NUM
Definition switchtec.h:299
@ SWITCHTEC_IMG_PART_TYPE_RSVD_15
Definition switchtec.h:297
@ SWITCHTEC_IMG_PART_TYPE_RSVD_11
Definition switchtec.h:293
@ SWITCHTEC_IMG_PART_TYPE_RSVD_8
Definition switchtec.h:290
@ SWITCHTEC_IMG_PART_TYPE_BL2
Definition switchtec.h:284
@ SWITCHTEC_IMG_PART_TYPE_RSVD_10
Definition switchtec.h:292
@ SWITCHTEC_IMG_PART_TYPE_KMT
Definition switchtec.h:283
@ SWITCHTEC_IMG_PART_TYPE_RSVD_5
Definition switchtec.h:287
@ SWITCHTEC_IMG_PART_TYPE_MAP
Definition switchtec.h:282
@ SWITCHTEC_IMG_PART_TYPE_DATA
Definition switchtec.h:285
@ SWITCHTEC_IMG_PART_TYPE_RSVD_12
Definition switchtec.h:294
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.
Definition diag.c:2130
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.
Definition diag.c:2344
switchtec_log_def_type
Log definition data types.
Definition switchtec.h:254
int switchtec_diag_refclk_status(struct switchtec_dev *dev, uint8_t *info)
Get the status of all stacks/CSUs of the refclk.
Definition diag.c:1651
__gas struct switchtec_gas * gasptr_t
Shortform for a pointer to the GAS register space.
Definition switchtec.h:88
switchtec_variant
The variant types of Switchtec device.
Definition switchtec.h:137
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.
Definition diag.c:2194
static const char * switchtec_phase_id_str(enum switchtec_boot_phase phase_id)
Return the phase string for a phase id.
Definition switchtec.h:713
int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id)
Enable cross hair on specified lane.
Definition diag.c:53
static int switchtec_is_gen6(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 6 device.
Definition switchtec.h:524
switchtec_event_type
There are three event types indicated by this enumeration: global, partition and port function.
Definition switchtec.h:1024
switchtec_log_type
Describe the type of logs too dump.
Definition switchtec.h:216
switchtec_event_special
Special event indexes numbers.
Definition switchtec.h:1015
switchtec_boot_phase
Device boot phase.
Definition switchtec.h:116
static const float switchtec_gen_transfers[]
Number of GT/s capable for each PCI generation or link_rate.
Definition switchtec.h:729
int switchtec_diag_eye_cancel(struct switchtec_dev *dev)
Cancel in-progress eye capture.
Definition diag.c:463
static int switchtec_is_gen4(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 4 device.
Definition switchtec.h:508
static int switchtec_is_paxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX-A.
Definition switchtec.h:633
static int switchtec_max_supported_ports(struct switchtec_dev *dev)
Return the max number of ports of a Switchtec device.
Definition switchtec.h:532
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.
Definition diag.c:690
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.
Definition diag.c:1151
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,...
Definition diag.c:2222
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.
Definition diag.c:227
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.
Definition diag.c:88
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.
Definition diag.c:590
int switchtec_inject_err_cto(struct switchtec_dev *dev, int phys_port_id)
Inject Credit Timeout error into a physical port.
Definition diag.c:2366
static int switchtec_is_pax(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX.
Definition switchtec.h:625
static int switchtec_is_psx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX(A).
Definition switchtec.h:608
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.
Definition diag.c:2323
int switchtec_diag_ltssm_clear(struct switchtec_dev *dev, int port)
Call the LTSSM clear MRPC command.
Definition diag.c:2149
static int switchtec_is_gen5(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 5 device.
Definition switchtec.h:516
static int switchtec_is_pfx(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX.
Definition switchtec.h:549
switchtec_event_flags
Event control flags.
Definition switchtec.h:996
int switchtec_diag_refclk_ctl(struct switchtec_dev *dev, int id, bool en)
Control the refclk output for a stack or CSU.
Definition diag.c:1622
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.
Definition diag.c:2302
switchtec_fw_dlstatus
Firmware update status.
Definition switchtec.h:1054
int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern type)
Setup Pattern Monitor.
Definition diag.c:747
static const char * switchtec_fw_image_gen_str(struct switchtec_fw_image_info *inf)
Return the generation string of a Switchtec fw image.
Definition switchtec.h:680
static const float switchtec_gen_datarate[]
Number of GB/s capable for each PCI generation or link_rate.
Definition switchtec.h:731
static int switchtec_is_pax_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX(A).
Definition switchtec.h:641
#define SWITCHTEC_OSA_MAX_ENTRIES
OSA capture data collection.
Definition switchtec.h:1772
static const char * switchtec_variant_str(struct switchtec_dev *dev)
Return the variant string of a Switchtec device.
Definition switchtec.h:694
switchtec_parition_types
Device parition types GEN5.
Definition switchtec.h:126
static int switchtec_is_gen3(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 3 device.
Definition switchtec.h:500