Velocity Userspace
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 
33 #include "mrpc.h"
34 #include "bind.h"
35 #include "portable.h"
36 #include "registers.h"
37 #include "utils.h"
38 
39 #include <stdbool.h>
40 #include <stdlib.h>
41 #include <stdint.h>
42 #include <stdio.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 struct switchtec_dev;
49 
50 #define SWITCHTEC_MAX_PARTS 48
51 #define SWITCHTEC_MAX_PORTS 60
52 #define SWITCHTEC_MAX_LANES 100
53 #define SWITCHTEC_MAX_STACKS 8
54 #define SWITCHTEC_PORTS_PER_STACK 8
55 #define SWITCHTEC_MAX_EVENT_COUNTERS 64
56 #define SWITCHTEC_UNBOUND_PORT 255
57 #define SWITCHTEC_PFF_PORT_VEP 100
58 
59 #define SWITCHTEC_FLASH_BOOT_PART_START 0xa8000000
60 #define SWITCHTEC_FLASH_MAP0_PART_START 0xa8020000
61 #define SWITCHTEC_FLASH_MAP1_PART_START 0xa8040000
62 #define SWITCHTEC_FLASH_PART_LEN 0x10000
63 
64 #define SWITCHTEC_CMD_MASK 0xffff
65 #define SWITCHTEC_PAX_ID_SHIFT 18
66 #define SWITCHTEC_PAX_ID_MASK 0x1f
67 #define SWITCHTEC_PAX_ID_LOCAL SWITCHTEC_PAX_ID_MASK
68 
69 #define SWITCHTEC_UT_MRPC_CMD_START 0x200
70 #define SWITCHTEC_UT_MRPC_CMD_END 0x23F
71 
72 #ifdef __CHECKER__
73 #define __gas __attribute__((noderef, address_space(1)))
74 #else
75 #define __gas
76 #endif
77 
78 #define _PURE __attribute__ ((pure))
79 
83 typedef __gas struct switchtec_gas *gasptr_t;
84 #define SWITCHTEC_MAP_FAILED ((gasptr_t) -1)
85 
90  SWITCHTEC_GEN3,
91  SWITCHTEC_GEN4,
92  SWITCHTEC_GEN5,
93  SWITCHTEC_GEN_UNKNOWN,
94 };
95 
99 enum stmfd_rev {
100  STMFD_REVA,
101  STMFD_REV_UNKNOWN = 0xff
102 };
103 
108  SWITCHTEC_REVA = 0x0f,
109  SWITCHTEC_REVB = 0x00,
110  SWITCHTEC_REVC = 0x01,
111  SWITCHTEC_REV_UNKNOWN = 0xff
112 };
113 
118  SWITCHTEC_BOOT_PHASE_BL1 = 1,
119  SWITCHTEC_BOOT_PHASE_BL2,
120  SWITCHTEC_BOOT_PHASE_FW,
121  SWITCHTEC_BOOT_PHASE_UNKNOWN
122 };
123 
128  STMFD_RCVRY_BL1_STRAP = 1,
129  STMFD_RCVRY_BL1_ASSERT,
130  STMFD_RCVRY_BL2_STRAP,
131  STMFD_RCVRY_BL2_ASSERT,
132  STMFD_RCVRY_BL2_EXEC,
133  STMFD_RCVRY_MAINFW,
134  STMFD_RCVRY_INVALID = 0xFF
135 };
136 
141  SWITCHTEC_PFX,
142  SWITCHTEC_PFXL,
143  SWITCHTEC_PFXI,
144  SWITCHTEC_PSX,
145  SWITCHTEC_PAX,
146  SWITCHTEC_PAXA,
147  SWITCHTEC_PFXA,
148  SWITCHTEC_PSXA,
149  SWITCHTEC_VAR_UNKNOWN,
150 };
151 
156  char name[256];
157  char desc[256];
158  char pci_dev[256];
159  char product_id[32];
160  char product_rev[8];
161  char fw_version[32];
162  char path[PATH_MAX];
163 };
164 
169  unsigned char partition;
170 
171  unsigned char stack;
172  unsigned char upstream;
173  unsigned char stk_id;
174  unsigned char phys_id;
175  unsigned char log_id;
176 };
177 
186  unsigned char cfg_lnk_width;
187  unsigned char neg_lnk_width;
188  unsigned char link_up;
189  unsigned char link_rate;
190  uint16_t ltssm;
191  const char *ltssm_str;
192  unsigned char lane_reversal;
193  const char *lane_reversal_str;
194  unsigned char first_act_lane;
195  char lanes[17];
196 
197  char *pci_bdf;
198  char *pci_bdf_path;
199 
200  char *pci_dev;
201  int vendor_id;
202  int device_id;
204  unsigned int acs_ctrl;
205 };
206 
208  enum stmfd_rcvry_reason rcvry_entry_reason;
209  uint8_t ping_rev;
210  uint8_t hw_rev;
211  uint32_t strap_stat;
212  uint32_t fw_version;
213  uint32_t spi_freq;
214  uint8_t dev_family;
215 };
216 
221  SWITCHTEC_BW_TYPE_RAW = 0x0,
222  SWITCHTEC_BW_TYPE_PAYLOAD = 0x1,
223 };
224 
230  SWITCHTEC_LOG_RAM,
231  SWITCHTEC_LOG_FLASH,
232  SWITCHTEC_LOG_MEMLOG,
233  SWITCHTEC_LOG_REGS,
234  SWITCHTEC_LOG_SYS_STACK,
235  SWITCHTEC_LOG_THRD_STACK,
236  SWITCHTEC_LOG_THRD,
237  SWITCHTEC_LOG_NVHDR,
238 };
239 
244  SWITCHTEC_LOG_PARSE_TYPE_APP,
245  SWITCHTEC_LOG_PARSE_TYPE_MAILBOX
246 };
247 
252  unsigned int log_fw_version;
253  unsigned int log_sdk_version;
254  unsigned int def_fw_version;
255  unsigned int def_sdk_version;
256  bool version_mismatch;
257  bool overflow;
258  bool gen_unknown;
259  bool gen_ignored;
260 };
261 
266  SWITCHTEC_LOG_DEF_TYPE_APP,
267  SWITCHTEC_LOG_DEF_TYPE_MAILBOX
268 };
269 
270 enum switchtec_fw_type {
271  SWITCHTEC_FW_TYPE_UNKNOWN = 0,
272  SWITCHTEC_FW_TYPE_BOOT,
273  SWITCHTEC_FW_TYPE_MAP,
274  SWITCHTEC_FW_TYPE_IMG,
275  SWITCHTEC_FW_TYPE_CFG,
276  SWITCHTEC_FW_TYPE_NVLOG,
277  SWITCHTEC_FW_TYPE_SEEPROM,
278  SWITCHTEC_FW_TYPE_KEY,
279  SWITCHTEC_FW_TYPE_BL2,
280 };
281 
287  unsigned long part_id;
288  enum switchtec_fw_type type;
289  char version[32];
290  size_t part_addr;
291  size_t part_len;
293  size_t image_len;
294  unsigned long image_crc;
295 
296  bool valid;
297  bool active;
298  bool running;
299  bool read_only;
300 
301  struct switchtec_fw_image_info *next;
302  void *metadata;
303 
304  unsigned long secure_version;
305  bool signed_image;
306 };
307 
310  struct switchtec_fw_image_info *active, *inactive;
311  } boot, map, img, cfg, nvlog, seeprom, key, bl2;
312 
313  struct switchtec_fw_image_info *mult_cfg;
314 
315  int nr_info;
316  struct switchtec_fw_image_info all[];
317 };
318 
323  uint64_t global;
324  uint64_t part_bitmap;
325  unsigned local_part;
326 
328  unsigned part[SWITCHTEC_MAX_PARTS];
329 
331  unsigned pff[SWITCHTEC_MAX_PFF_CSR];
332 };
333 
338  SWITCHTEC_EVT_INVALID = -1,
339  SWITCHTEC_GLOBAL_EVT_STACK_ERROR,
340  SWITCHTEC_GLOBAL_EVT_PPU_ERROR,
341  SWITCHTEC_GLOBAL_EVT_ISP_ERROR,
342  SWITCHTEC_GLOBAL_EVT_SYS_RESET,
343  SWITCHTEC_GLOBAL_EVT_FW_EXC,
344  SWITCHTEC_GLOBAL_EVT_FW_NMI,
345  SWITCHTEC_GLOBAL_EVT_FW_NON_FATAL,
346  SWITCHTEC_GLOBAL_EVT_FW_FATAL,
347  SWITCHTEC_GLOBAL_EVT_TWI_MRPC_COMP,
348  SWITCHTEC_GLOBAL_EVT_TWI_MRPC_COMP_ASYNC,
349  SWITCHTEC_GLOBAL_EVT_CLI_MRPC_COMP,
350  SWITCHTEC_GLOBAL_EVT_CLI_MRPC_COMP_ASYNC,
351  SWITCHTEC_GLOBAL_EVT_GPIO_INT,
352  SWITCHTEC_GLOBAL_EVT_GFMS,
353  SWITCHTEC_PART_EVT_PART_RESET,
354  SWITCHTEC_PART_EVT_MRPC_COMP,
355  SWITCHTEC_PART_EVT_MRPC_COMP_ASYNC,
356  SWITCHTEC_PART_EVT_DYN_PART_BIND_COMP,
357  SWITCHTEC_PFF_EVT_AER_IN_P2P,
358  SWITCHTEC_PFF_EVT_AER_IN_VEP,
359  SWITCHTEC_PFF_EVT_DPC,
360  SWITCHTEC_PFF_EVT_CTS,
361  SWITCHTEC_PFF_EVT_UEC,
362  SWITCHTEC_PFF_EVT_HOTPLUG,
363  SWITCHTEC_PFF_EVT_IER,
364  SWITCHTEC_PFF_EVT_THRESH,
365  SWITCHTEC_PFF_EVT_POWER_MGMT,
366  SWITCHTEC_PFF_EVT_TLP_THROTTLING,
367  SWITCHTEC_PFF_EVT_FORCE_SPEED,
368  SWITCHTEC_PFF_EVT_CREDIT_TIMEOUT,
369  SWITCHTEC_PFF_EVT_LINK_STATE,
370  SWITCHTEC_MAX_EVENTS,
371 };
372 
373 /*********** Platform Functions ***********/
374 
375 struct switchtec_dev *switchtec_open(const char *device);
376 struct switchtec_dev *switchtec_open_by_path(const char *path);
377 struct switchtec_dev *switchtec_open_by_index(int index);
378 struct switchtec_dev *switchtec_open_by_pci_addr(int domain, int bus,
379  int device, int func);
380 struct switchtec_dev *switchtec_open_i2c(const char *path, int i2c_addr);
381 struct switchtec_dev *switchtec_open_i2c_by_adapter(int adapter, int i2c_addr);
382 struct switchtec_dev *switchtec_open_uart(int fd);
383 struct switchtec_dev *switchtec_open_eth(const char *ip, const int inst);
384 
385 void switchtec_close(struct switchtec_dev *dev);
386 int switchtec_list(struct switchtec_device_info **devlist);
387 void switchtec_list_free(struct switchtec_device_info *devlist);
388 int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf,
389  size_t buflen);
390 int switchtec_cmd(struct switchtec_dev *dev, uint32_t cmd,
391  const void *payload, size_t payload_len, void *resp,
392  size_t resp_len);
393 int switchtec_get_devices(struct switchtec_dev *dev,
394  struct switchtec_status *status,
395  int ports);
396 int switchtec_pff_to_port(struct switchtec_dev *dev, int pff,
397  int *partition, int *port);
398 int switchtec_port_to_pff(struct switchtec_dev *dev, int partition,
399  int port, int *pff);
400 int switchtec_event_summary(struct switchtec_dev *dev,
401  struct switchtec_event_summary *sum);
402 int switchtec_event_check(struct switchtec_dev *dev,
403  struct switchtec_event_summary *check,
404  struct switchtec_event_summary *res);
405 int switchtec_event_ctl(struct switchtec_dev *dev,
406  enum switchtec_event_id e,
407  int index, int flags,
408  uint32_t data[5]);
409 int switchtec_event_wait(struct switchtec_dev *dev, int timeout_ms);
410 
411 /*********** Generic Accessors ***********/
412 
413 _PURE const char *switchtec_name(struct switchtec_dev *dev);
414 _PURE int switchtec_partition(struct switchtec_dev *dev);
415 _PURE int switchtec_device_id(struct switchtec_dev *dev);
416 _PURE enum switchtec_gen switchtec_gen(struct switchtec_dev *dev);
417 _PURE enum switchtec_variant switchtec_variant(struct switchtec_dev *dev);
418 _PURE enum switchtec_boot_phase
419 switchtec_boot_phase(struct switchtec_dev *dev);
420 int switchtec_set_pax_id(struct switchtec_dev *dev, int pax_id);
421 int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output);
422 int switchtec_hard_reset(struct switchtec_dev *dev);
423 int switchtec_status(struct switchtec_dev *dev,
424  struct switchtec_status **status);
425 void switchtec_status_free(struct switchtec_status *status, int ports);
426 int switchtec_get_device_info(struct switchtec_dev *dev,
427  enum switchtec_boot_phase *phase,
428  enum switchtec_gen *gen,
429  enum switchtec_rev *rev,
430  struct ping_dev_info *ping_info);
431 const char *switchtec_strerror(void);
432 void switchtec_perror(const char *str);
433 int switchtec_log_to_file(struct switchtec_dev *dev,
434  enum switchtec_log_type type, int fd, FILE *log_def_file,
435  struct switchtec_log_file_info *info);
436 int switchtec_parse_log(FILE *bin_log_file, FILE *log_def_file,
437  FILE *parsed_log_file,
438  enum switchtec_log_parse_type log_type,
439  enum switchtec_gen gen,
440  struct switchtec_log_file_info *info);
441 int switchtec_log_def_to_file(struct switchtec_dev *dev,
442  enum switchtec_log_def_type type,
443  FILE* file);
444 float switchtec_die_temp(struct switchtec_dev *dev);
445 int switchtec_calc_lane_id(struct switchtec_dev *dev, int phys_port_id,
446  int lane_id, struct switchtec_status *port);
447 int switchtec_calc_port_lane(struct switchtec_dev *dev, int lane_id,
448  int *phys_port_id, int *port_lane_id,
449  struct switchtec_status *port);
450 int switchtec_calc_lane_mask(struct switchtec_dev *dev, int phys_port_id,
451  int lane_id, int num_lanes, int *lane_mask,
452  struct switchtec_status *port);
453 
457 static inline int switchtec_is_gen3(struct switchtec_dev *dev)
458 {
459  return switchtec_gen(dev) == SWITCHTEC_GEN3;
460 }
461 
465 static inline int switchtec_is_gen4(struct switchtec_dev *dev)
466 {
467  return switchtec_gen(dev) == SWITCHTEC_GEN4;
468 }
469 
473 static inline int switchtec_is_gen5(struct switchtec_dev *dev)
474 {
475  return switchtec_gen(dev) == SWITCHTEC_GEN5;
476 }
477 
481 static inline int switchtec_max_supported_ports(struct switchtec_dev *dev)
482 {
483  return switchtec_is_gen5(dev) ? SWITCHTEC_MAX_PORTS :
484  switchtec_is_gen4(dev) ? 52 : 48;
485 }
486 
490 static inline int switchtec_is_pfx(struct switchtec_dev *dev)
491 {
492  return switchtec_variant(dev) == SWITCHTEC_PFX;
493 }
494 
498 static inline int switchtec_is_pfxl(struct switchtec_dev *dev)
499 {
500  return switchtec_variant(dev) == SWITCHTEC_PFXL;
501 }
502 
506 static inline int switchtec_is_pfxi(struct switchtec_dev *dev)
507 {
508  return switchtec_variant(dev) == SWITCHTEC_PFXI;
509 }
510 
514 static inline int switchtec_is_pfxa(struct switchtec_dev *dev)
515 {
516  return switchtec_variant(dev) == SWITCHTEC_PFXA;
517 }
518 
522 static inline int switchtec_is_pfx_all(struct switchtec_dev *dev)
523 {
524  return switchtec_is_pfx(dev) ||
525  switchtec_is_pfxl(dev) ||
526  switchtec_is_pfxi(dev) ||
527  switchtec_is_pfxa(dev);
528 }
529 
533 static inline int switchtec_is_psx(struct switchtec_dev *dev)
534 {
535  return switchtec_variant(dev) == SWITCHTEC_PSX;
536 }
537 
541 static inline int switchtec_is_psxa(struct switchtec_dev *dev)
542 {
543  return switchtec_variant(dev) == SWITCHTEC_PSXA;
544 }
545 
549 static inline int switchtec_is_psx_all(struct switchtec_dev *dev)
550 {
551  return switchtec_is_psx(dev) ||
552  switchtec_is_psxa(dev);
553 }
554 
558 static inline int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
559 {
560  return switchtec_is_psx_all(dev) || switchtec_is_pfx_all(dev);
561 }
562 
566 static inline int switchtec_is_pax(struct switchtec_dev *dev)
567 {
568  return switchtec_variant(dev) == SWITCHTEC_PAX;
569 }
570 
574 static inline int switchtec_is_paxa(struct switchtec_dev *dev)
575 {
576  return switchtec_variant(dev) == SWITCHTEC_PAXA;
577 }
578 
582 static inline int switchtec_is_pax_all(struct switchtec_dev *dev)
583 {
584  return switchtec_is_pax(dev) || switchtec_is_paxa(dev);
585 }
586 
590 static inline const char *switchtec_gen_str(struct switchtec_dev *dev)
591 {
592  const char *str;
593 
594  str = switchtec_is_gen3(dev) ? "GEN3" :
595  switchtec_is_gen4(dev) ? "GEN4" :
596  switchtec_is_gen5(dev) ? "GEN5" : "Unknown";
597 
598  return str;
599 }
600 
604 static inline const char *stmfd_rev_str(uint8_t rev)
605 {
606  const char *str;
607 
608  str = (rev == STMFD_REVA) ? "REVA" : "Unknown";
609 
610  return str;
611 }
612 
616 static inline const char *switchtec_rev_str(enum switchtec_rev rev)
617 {
618  const char *str;
619 
620  str = (rev == SWITCHTEC_REVA) ? "REVA" :
621  (rev == SWITCHTEC_REVB) ? "REVB" :
622  (rev == SWITCHTEC_REVC) ? "REVC" : "Unknown";
623 
624  return str;
625 }
626 
630 static inline const char *
632 {
633  switch (inf->gen) {
634  case SWITCHTEC_GEN3: return "GEN3";
635  case SWITCHTEC_GEN4: return "GEN4";
636  case SWITCHTEC_GEN5: return "GEN5";
637  default: return "UNKNOWN";
638  }
639 }
640 
644 static inline const char *switchtec_variant_str(struct switchtec_dev *dev)
645 {
646  const char *str;
647 
648  str = switchtec_is_pfx(dev) ? "PFX" :
649  switchtec_is_pfxl(dev) ? "PFX-L" :
650  switchtec_is_pfxi(dev) ? "PFX-I" :
651  switchtec_is_psx(dev) ? "PSX" :
652  switchtec_is_pax(dev) ? "PAX" :
653  switchtec_is_pfxa(dev) ? "PFX-A" :
654  switchtec_is_psxa(dev) ? "PSX-A" :
655  switchtec_is_paxa(dev) ? "PAX-A" : "Unknown";
656 
657  return str;
658 }
659 
663 static inline const char* switchtec_phase_id_str(
664  enum switchtec_boot_phase phase_id)
665 {
666  switch(phase_id) {
667  case SWITCHTEC_BOOT_PHASE_BL1:
668  return "BL1";
669  case SWITCHTEC_BOOT_PHASE_BL2:
670  return "BL2";
671  case SWITCHTEC_BOOT_PHASE_FW:
672  return "Main Firmware";
673  default:
674  return "Unknown Phase";
675  }
676 }
677 
679 static const float switchtec_gen_transfers[] = {0, 2.5, 5, 8, 16, 32};
681 static const float switchtec_gen_datarate[] = {0, 250, 500, 985, 1969, 3938};
682 
683 static inline const char *switchtec_ltssm_str(int ltssm, int show_minor)
684 {
685  if (!show_minor)
686  ltssm |= 0xFF00;
687 
688  switch(ltssm) {
689  case 0x0000: return "Detect (INACTIVE)";
690  case 0x0100: return "Detect (QUIET)";
691  case 0x0200: return "Detect (SPD_CHD0)";
692  case 0x0300: return "Detect (SPD_CHD1)";
693  case 0x0400: return "Detect (ACTIVE0)";
694  case 0x0500: return "Detect (ACTIVE1)";
695  case 0x0600: return "Detect (P1_TO_P0)";
696  case 0x0700: return "Detect (P0_TO_P1_0)";
697  case 0x0800: return "Detect (P0_TO_P1_1)";
698  case 0x0900: return "Detect (P0_TO_P1_2)";
699  case 0xFF00: return "Detect";
700  case 0x0001: return "Polling (INACTIVE)";
701  case 0x0101: return "Polling (ACTIVE_ENTRY)";
702  case 0x0201: return "Polling (ACTIVE)";
703  case 0x0301: return "Polling (CFG)";
704  case 0x0401: return "Polling (COMP)";
705  case 0x0501: return "Polling (COMP_ENTRY)";
706  case 0x0601: return "Polling (COMP_EIOS)";
707  case 0x0701: return "Polling (COMP_EIOS_ACK)";
708  case 0x0801: return "Polling (COMP_IDLE)";
709  case 0xFF01: return "Polling";
710  case 0x0002: return "Config (INACTIVE)";
711  case 0x0102: return "Config (US_LW_START)";
712  case 0x0202: return "Config (US_LW_ACCEPT)";
713  case 0x0302: return "Config (US_LN_WAIT)";
714  case 0x0402: return "Config (US_LN_ACCEPT)";
715  case 0x0502: return "Config (DS_LW_START)";
716  case 0x0602: return "Config (DS_LW_ACCEPT)";
717  case 0x0702: return "Config (DS_LN_WAIT)";
718  case 0x0802: return "Config (DS_LN_ACCEPT)";
719  case 0x0902: return "Config (COMPLETE)";
720  case 0x0A02: return "Config (IDLE)";
721  case 0xFF02: return "Config";
722  case 0x0003: return "L0 (INACTIVE)";
723  case 0x0103: return "L0 (L0)";
724  case 0x0203: return "L0 (TX_EL_IDLE)";
725  case 0x0303: return "L0 (TX_IDLE_MIN)";
726  case 0xFF03: return "L0";
727  case 0x0004: return "Recovery (INACTIVE)";
728  case 0x0104: return "Recovery (RCVR_LOCK)";
729  case 0x0204: return "Recovery (RCVR_CFG)";
730  case 0x0304: return "Recovery (IDLE)";
731  case 0x0404: return "Recovery (SPEED0)";
732  case 0x0504: return "Recovery (SPEED1)";
733  case 0x0604: return "Recovery (SPEED2)";
734  case 0x0704: return "Recovery (SPEED3)";
735  case 0x0804: return "Recovery (EQ_PH0)";
736  case 0x0904: return "Recovery (EQ_PH1)";
737  case 0x0A04: return "Recovery (EQ_PH2)";
738  case 0x0B04: return "Recovery (EQ_PH3)";
739  case 0xFF04: return "Recovery";
740  case 0x0005: return "Disable (INACTIVE)";
741  case 0x0105: return "Disable (DISABLE0)";
742  case 0x0205: return "Disable (DISABLE1)";
743  case 0x0305: return "Disable (DISABLE2)";
744  case 0x0405: return "Disable (DISABLE3)";
745  case 0xFF05: return "Disable";
746  case 0x0006: return "Loop Back (INACTIVE)";
747  case 0x0106: return "Loop Back (ENTRY)";
748  case 0x0206: return "Loop Back (ENTRY_EXIT)";
749  case 0x0306: return "Loop Back (EIOS)";
750  case 0x0406: return "Loop Back (EIOS_ACK)";
751  case 0x0506: return "Loop Back (IDLE)";
752  case 0x0606: return "Loop Back (ACTIVE)";
753  case 0x0706: return "Loop Back (EXIT0)";
754  case 0x0806: return "Loop Back (EXIT1)";
755  case 0xFF06: return "Loop Back";
756  case 0x0007: return "Hot Reset (INACTIVE)";
757  case 0x0107: return "Hot Reset (HOT_RESET)";
758  case 0x0207: return "Hot Reset (MASTER_UP)";
759  case 0x0307: return "Hot Reset (MASTER_DOWN)";
760  case 0xFF07: return "Hot Reset";
761  case 0x0008: return "TxL0s (INACTIVE)";
762  case 0x0108: return "TxL0s (IDLE)";
763  case 0x0208: return "TxL0s (T0_L0)";
764  case 0x0308: return "TxL0s (FTS0)";
765  case 0x0408: return "TxL0s (FTS1)";
766  case 0xFF08: return "TxL0s";
767  case 0x0009: return "L1 (INACTIVE)";
768  case 0x0109: return "L1 (IDLE)";
769  case 0x0209: return "L1 (SUBSTATE)";
770  case 0x0309: return "L1 (SPD_CHG1)";
771  case 0x0409: return "L1 (T0_L0)";
772  case 0xFF09: return "L1";
773  case 0x000A: return "L2 (INACTIVE)";
774  case 0x010A: return "L2 (IDLE)";
775  case 0x020A: return "L2 (TX_WAKE0)";
776  case 0x030A: return "L2 (TX_WAKE1)";
777  case 0x040A: return "L2 (EXIT)";
778  case 0x050A: return "L2 (SPEED)";
779  case 0xFF0A: return "L2";
780  default: return "UNKNOWN";
781  }
782 
783 }
784 
785 /*********** EVENT Handling ***********/
786 
792  SWITCHTEC_EVT_FLAG_CLEAR = 1 << 0,
793  SWITCHTEC_EVT_FLAG_EN_POLL = 1 << 1,
794  SWITCHTEC_EVT_FLAG_EN_LOG = 1 << 2,
795  SWITCHTEC_EVT_FLAG_EN_CLI = 1 << 3,
796  SWITCHTEC_EVT_FLAG_EN_FATAL = 1 << 4,
797  SWITCHTEC_EVT_FLAG_DIS_POLL = 1 << 5,
798  SWITCHTEC_EVT_FLAG_DIS_LOG = 1 << 6,
799  SWITCHTEC_EVT_FLAG_DIS_CLI = 1 << 7,
800  SWITCHTEC_EVT_FLAG_DIS_FATAL = 1 << 8,
801 };
802 
811  SWITCHTEC_EVT_IDX_LOCAL = -1,
812  SWITCHTEC_EVT_IDX_ALL = -2,
813 };
814 
820  SWITCHTEC_EVT_GLOBAL,
821  SWITCHTEC_EVT_PART,
822  SWITCHTEC_EVT_PFF,
823 };
824 
826  enum switchtec_event_id e,
827  int index);
829  enum switchtec_event_id e,
830  int index);
832  enum switchtec_event_id *e,
833  int *idx);
835  const char **name,
836  const char **desc);
837 int switchtec_event_wait_for(struct switchtec_dev *dev,
838  enum switchtec_event_id e, int index,
839  struct switchtec_event_summary *res,
840  int timeout_ms);
841 
842 /******** FIRMWARE Management ********/
843 
849  SWITCHTEC_DLSTAT_READY = 0x0,
850  SWITCHTEC_DLSTAT_INPROGRESS = 0x1,
851  SWITCHTEC_DLSTAT_HEADER_INCORRECT = 0x2,
852  SWITCHTEC_DLSTAT_OFFSET_INCORRECT = 0x3,
853  SWITCHTEC_DLSTAT_CRC_INCORRECT = 0x4,
854  SWITCHTEC_DLSTAT_LENGTH_INCORRECT = 0x5,
855  SWITCHTEC_DLSTAT_HARDWARE_ERR = 0x6,
856  SWITCHTEC_DLSTAT_COMPLETES = 0x7,
857  SWITCHTEC_DLSTAT_SUCCESS_FIRM_ACT = 0x8,
858  SWITCHTEC_DLSTAT_SUCCESS_DATA_ACT = 0x9,
859  SWITCHTEC_DLSTAT_PACKAGE_TOO_SMALL = 0xa,
860  SWITCHTEC_DLSTAT_SIG_MEM_ALLOC = 0xb,
861  SWITCHTEC_DLSTAT_SEEPROM = 0xc,
862  SWITCHTEC_DLSTAT_READONLY_PARTITION = 0xd,
863  SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT = 0xe,
864  SWITCHTEC_DLSTAT_SEEPROM_TWI_NOT_ENABLED = 0xf,
865  SWITCHTEC_DLSTAT_PROGRAM_RUNNING = 0x10,
866  SWITCHTEC_DLSTAT_NOT_ALLOWED = 0x11,
867  SWITCHTEC_DLSTAT_XML_MISMATCH_ACT = 0x12,
868  SWITCHTEC_DLSTAT_UNKNOWN_ACT = 0x13,
869  SWITCHTEC_DLSTAT_METADATA_BUFFER_OVERFLOW = 0x14,
870  SWITCHTEC_DLSTAT_METADATA_LEN_INCORRECT = 0x15,
871  SWITCHTEC_DLSTAT_FLM_NOT_INIT = 0x16,
872 
873  SWITCHTEC_DLSTAT_ERROR_PROGRAM = 0x1000,
874  SWITCHTEC_DLSTAT_ERROR_OFFSET = 0x1001,
875 
876  SWITCHTEC_DLSTAT_NO_FILE = 0x7d009,
877 };
878 
883  SWITCHTEC_FW_RW = 0,
884  SWITCHTEC_FW_RO = 1,
885 };
886 
887 int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
888  int toggle_bl2, int toggle_key,
889  int toggle_fw, int toggle_cfg);
890 int switchtec_fw_write_fd(struct switchtec_dev *dev, int img_fd,
891  int dont_activate, int force,
892  void (*progress_callback)(int cur, int tot));
893 int switchtec_fw_write_file(struct switchtec_dev *dev, FILE *fimg,
894  int dont_activate, int force,
895  void (*progress_callback)(int cur, int tot));
896 int switchtec_fw_read_fd(struct switchtec_dev *dev, int fd,
897  unsigned long addr, size_t len,
898  void (*progress_callback)(int cur, int tot));
899 int switchtec_fw_body_read_fd(struct switchtec_dev *dev, int fd,
900  struct switchtec_fw_image_info *info,
901  void (*progress_callback)(int cur, int tot));
902 int switchtec_fw_read(struct switchtec_dev *dev, unsigned long addr,
903  size_t len, void *buf);
904 void switchtec_fw_perror(const char *s, int ret);
905 int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info);
906 int switchtec_get_device_id_bl2(struct switchtec_dev *dev,
907  unsigned short *device_id);
908 int switchtec_fw_file_secure_version_newer(struct switchtec_dev *dev,
909  int img_fd);
910 const char *switchtec_fw_image_type(const struct switchtec_fw_image_info *info);
912 switchtec_fw_part_summary(struct switchtec_dev *dev);
914 int switchtec_fw_img_write_hdr(int fd, struct switchtec_fw_image_info *info);
915 int switchtec_fw_is_boot_ro(struct switchtec_dev *dev);
916 int switchtec_fw_set_boot_ro(struct switchtec_dev *dev,
917  enum switchtec_fw_ro ro);
918 enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version);
919 int switchtec_bind_info(struct switchtec_dev *dev,
920  struct switchtec_bind_status_out *bind_status,
921  int phy_port);
922 int switchtec_bind(struct switchtec_dev *dev, int par_id,
923  int log_port, int phy_port);
924 int switchtec_unbind(struct switchtec_dev *dev, int par_id, int log_port);
925 bool switchtec_stack_bif_port_valid(struct switchtec_dev *dev, int stack_id,
926  int port_id);
927 int switchtec_stack_bif_width(struct switchtec_dev *dev, int stack_id,
928  int port_bif);
929 int switchtec_get_stack_bif(struct switchtec_dev *dev, int stack_id,
930  int port_bif[SWITCHTEC_PORTS_PER_STACK]);
931 int switchtec_set_stack_bif(struct switchtec_dev *dev, int stack_id,
932  int port_bif[SWITCHTEC_PORTS_PER_STACK]);
933 
934 /********** EVENT COUNTER *********/
935 
940  UNSUP_REQ_ERR = 1 << 0,
941  ECRC_ERR = 1 << 1,
942  MALFORM_TLP_ERR = 1 << 2,
943  RCVR_OFLOW_ERR = 1 << 3,
944  CMPLTR_ABORT_ERR = 1 << 4,
945  POISONED_TLP_ERR = 1 << 5,
946  SURPRISE_DOWN_ERR = 1 << 6,
948  HDR_LOG_OFLOW_ERR = 1 << 8,
949  UNCOR_INT_ERR = 1 << 9,
950  REPLAY_TMR_TIMEOUT = 1 << 10,
952  BAD_DLLP = 1 << 12,
953  BAD_TLP = 1 << 13,
954  RCVR_ERR = 1 << 14,
955  RCV_FATAL_MSG = 1 << 15,
956  RCV_NON_FATAL_MSG = 1 << 16,
957  RCV_CORR_MSG = 1 << 17,
958  NAK_RCVD = 1 << 18,
959  RULE_TABLE_HIT = 1 << 19,
960  POSTED_TLP = 1 << 20,
961  COMP_TLP = 1 << 21,
962  NON_POSTED_TLP = 1 << 22,
963 
978 
982  ALL = (1 << 23) - 1,
983 };
984 
989 extern const struct switchtec_evcntr_type_list {
990  enum switchtec_evcntr_type_mask mask;
991  const char *name;
992  const char *help;
994 
999  unsigned port_mask; //<! Mask of ports this counter counts
1000 
1003  int egress; //<! If 1, count egress, otherwise on ingress
1004 
1009  unsigned threshold;
1010 };
1011 
1012 int switchtec_evcntr_type_count(void);
1013 const char *switchtec_evcntr_type_str(int *type_mask);
1014 int switchtec_evcntr_setup(struct switchtec_dev *dev, unsigned stack_id,
1015  unsigned cntr_id,
1016  struct switchtec_evcntr_setup *setup);
1017 int switchtec_evcntr_get_setup(struct switchtec_dev *dev, unsigned stack_id,
1018  unsigned cntr_id, unsigned nr_cntrs,
1019  struct switchtec_evcntr_setup *res);
1020 int switchtec_evcntr_get(struct switchtec_dev *dev, unsigned stack_id,
1021  unsigned cntr_id, unsigned nr_cntrs, unsigned *res,
1022  int clear);
1023 int switchtec_evcntr_get_both(struct switchtec_dev *dev, unsigned stack_id,
1024  unsigned cntr_id, unsigned nr_cntrs,
1025  struct switchtec_evcntr_setup *setup,
1026  unsigned *counts, int clear);
1027 int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms);
1028 
1029 /********** BANDWIDTH COUNTER *********/
1030 
1035  uint64_t time_us;
1037  uint64_t posted;
1038  uint64_t comp;
1039  uint64_t nonposted;
1040  } egress,
1041  ingress;
1042 };
1043 
1044 void switchtec_bwcntr_sub(struct switchtec_bwcntr_res *new_cntr,
1045  struct switchtec_bwcntr_res *old_cntr);
1046 int switchtec_bwcntr_set_many(struct switchtec_dev *dev, int nr_ports,
1047  int * phys_port_ids,
1048  enum switchtec_bw_type bw_type);
1049 int switchtec_bwcntr_set_all(struct switchtec_dev *dev,
1050  enum switchtec_bw_type bw_type);
1051 int switchtec_bwcntr_many(struct switchtec_dev *dev, int nr_ports,
1052  int *phys_port_ids, int clear,
1053  struct switchtec_bwcntr_res *res);
1054 int switchtec_bwcntr_all(struct switchtec_dev *dev, int clear,
1055  struct switchtec_port_id **ports,
1056  struct switchtec_bwcntr_res **res);
1057 uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d);
1058 
1059 /********** LATENCY COUNTER *********/
1060 
1061 #define SWITCHTEC_LAT_ALL_INGRESS 63
1062 
1063 int switchtec_lat_setup_many(struct switchtec_dev *dev, int nr_ports,
1064  int *egress_port_ids, int *ingress_port_ids);
1065 int switchtec_lat_setup(struct switchtec_dev *dev, int egress_port_id,
1066  int ingress_port_id, int clear);
1067 int switchtec_lat_get_many(struct switchtec_dev *dev, int nr_ports,
1068  int clear, int *egress_port_ids,
1069  int *cur_ns, int *max_ns);
1070 int switchtec_lat_get(struct switchtec_dev *dev, int clear,
1071  int egress_port_ids, int *cur_ns,
1072  int *max_ns);
1073 
1074 /********** GLOBAL ADDRESS SPACE ACCESS *********/
1075 
1076 /*
1077  * GAS map maps the hardware registers into user memory space.
1078  * Needless to say, this can be very dangerous and should only
1079  * be done if you know what you are doing. Any register accesses
1080  * that use this will remain unsupported by Microsemi unless it's
1081  * done within the switchtec user project or otherwise specified.
1082  */
1083 
1084 gasptr_t switchtec_gas_map(struct switchtec_dev *dev, int writeable,
1085  size_t *map_size);
1086 void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map);
1087 
1088 /********** DIAGNOSTIC FUNCTIONS *********/
1089 
1090 #define SWITCHTEC_DIAG_CROSS_HAIR_ALL_LANES -1
1091 #define SWITCHTEC_DIAG_CROSS_HAIR_MAX_LANES 64
1092 
1093 enum switchtec_diag_cross_hair_state {
1094  SWITCHTEC_DIAG_CROSS_HAIR_DISABLED = 0,
1095  SWITCHTEC_DIAG_CROSS_HAIR_RESVD,
1096  SWITCHTEC_DIAG_CROSS_HAIR_WAITING,
1097  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_RIGHT,
1098  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_RIGHT,
1099  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_RIGHT,
1100  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_LEFT,
1101  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_LEFT,
1102  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_LEFT,
1103  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_TOP_RIGHT,
1104  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_TOP_RIGHT,
1105  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_TOP_RIGHT,
1106  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_BOT_RIGHT,
1107  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_BOT_RIGHT,
1108  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_BOT_RIGHT,
1109  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_TOP_LEFT,
1110  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_TOP_LEFT,
1111  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_TOP_LEFT,
1112  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_BOT_LEFT,
1113  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_BOT_LEFT,
1114  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_BOT_LEFT,
1115  SWITCHTEC_DIAG_CROSS_HAIR_DONE,
1116  SWITCHTEC_DIAG_CROSS_HAIR_ERROR,
1117 };
1118 
1120  enum switchtec_diag_cross_hair_state state;
1121  int lane_id;
1122 
1123  union {
1124  struct {
1125  /* Valid when state is Error */
1126  int prev_state;
1127  int x_pos;
1128  int y_pos;
1129  };
1130  /* Valid when state is DONE */
1131  struct {
1132  int eye_left_lim;
1133  int eye_right_lim;
1134  int eye_bot_left_lim;
1135  int eye_bot_right_lim;
1136  int eye_top_left_lim;
1137  int eye_top_right_lim;
1138  };
1139  };
1140 };
1141 
1143  int port_id;
1144  int lane_id;
1145  int ctle;
1146  int target_amplitude;
1147  int speculative_dfe;
1148  int dynamic_dfe[7];
1149 };
1150 
1152  int lane_cnt;
1153  struct {
1154  int pre;
1155  int post;
1156  } cursors[16];
1157 };
1158 
1160  int lane_id;
1161  int step_cnt;
1162 
1163  struct {
1164  int pre_cursor;
1165  int post_cursor;
1166  int fom;
1167  int pre_cursor_up;
1168  int post_cursor_up;
1169  int error_status;
1170  int active_status;
1171  int speed;
1172  } steps[126];
1173 };
1174 
1176  int fs;
1177  int lf;
1178 };
1179 
1181  int ctle2_rx_mode;
1182  int dtclk_5;
1183  int dtclk_8_6;
1184  int dtclk_9;
1185 };
1186 
1188  const char *tag;
1189  const char *desc;
1190  bool reserved;
1191 };
1192 
1193 enum switchtec_diag_eye_data_mode {
1194  SWITCHTEC_DIAG_EYE_RAW,
1195  SWITCHTEC_DIAG_EYE_RATIO,
1196 };
1197 
1198 enum switchtec_diag_loopback_enable {
1199  SWITCHTEC_DIAG_LOOPBACK_RX_TO_TX = 1 << 0,
1200  SWITCHTEC_DIAG_LOOPBACK_TX_TO_RX = 1 << 1,
1201  SWITCHTEC_DIAG_LOOPBACK_LTSSM = 1 << 2,
1202 };
1203 
1204 enum switchtec_diag_pattern {
1205  SWITCHTEC_DIAG_PATTERN_PRBS_7,
1206  SWITCHTEC_DIAG_PATTERN_PRBS_11,
1207  SWITCHTEC_DIAG_PATTERN_PRBS_23,
1208  SWITCHTEC_DIAG_PATTERN_PRBS_31,
1209  SWITCHTEC_DIAG_PATTERN_PRBS_9,
1210  SWITCHTEC_DIAG_PATTERN_PRBS_15,
1211  SWITCHTEC_DIAG_PATTERN_PRBS_DISABLED,
1212 };
1213 
1214 enum switchtec_diag_ltssm_speed {
1215  SWITCHTEC_DIAG_LTSSM_GEN1 = 0,
1216  SWITCHTEC_DIAG_LTSSM_GEN2 = 1,
1217  SWITCHTEC_DIAG_LTSSM_GEN3 = 2,
1218  SWITCHTEC_DIAG_LTSSM_GEN4 = 3,
1219 };
1220 
1221 enum switchtec_diag_end {
1222  SWITCHTEC_DIAG_LOCAL,
1223  SWITCHTEC_DIAG_FAR_END,
1224 };
1225 
1226 enum switchtec_diag_link {
1227  SWITCHTEC_DIAG_LINK_CURRENT,
1228  SWITCHTEC_DIAG_LINK_PREVIOUS,
1229 };
1230 
1232  unsigned int timestamp;
1233  float link_rate;
1234  int link_state;
1235 };
1236 
1237 int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id);
1238 int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev);
1239 int switchtec_diag_cross_hair_get(struct switchtec_dev *dev, int start_lane_id,
1240  int num_lanes, struct switchtec_diag_cross_hair *res);
1241 
1242 int switchtec_diag_eye_set_mode(struct switchtec_dev *dev,
1243  enum switchtec_diag_eye_data_mode mode);
1244 int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4],
1245  struct range *x_range, struct range *y_range,
1246  int step_interval);
1247 int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels,
1248  size_t pixel_cnt, int *lane_id);
1249 int switchtec_diag_eye_cancel(struct switchtec_dev *dev);
1250 
1251 int switchtec_diag_loopback_set(struct switchtec_dev *dev, int port_id,
1252  int enable, enum switchtec_diag_ltssm_speed ltssm_speed);
1253 int switchtec_diag_loopback_get(struct switchtec_dev *dev, int port_id,
1254  int *enabled, enum switchtec_diag_ltssm_speed *ltssm_speed);
1255 int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
1256  enum switchtec_diag_pattern type);
1257 int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
1258  enum switchtec_diag_pattern *type);
1259 int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,
1260  enum switchtec_diag_pattern type);
1261 int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id,
1262  int lane_id, enum switchtec_diag_pattern *type,
1263  unsigned long long *err_cnt);
1264 int switchtec_diag_pattern_inject(struct switchtec_dev *dev, int port_id,
1265  unsigned int err_cnt);
1266 
1267 int switchtec_diag_rcvr_obj(struct switchtec_dev *dev, int port_id,
1268  int lane_id, enum switchtec_diag_link link,
1269  struct switchtec_rcvr_obj *res);
1270 int switchtec_diag_rcvr_ext(struct switchtec_dev *dev, int port_id,
1271  int lane_id, enum switchtec_diag_link link,
1272  struct switchtec_rcvr_ext *res);
1273 
1274 int switchtec_diag_port_eq_tx_coeff(struct switchtec_dev *dev, int port_id,
1275  enum switchtec_diag_end end, enum switchtec_diag_link link,
1276  struct switchtec_port_eq_coeff *res);
1277 int switchtec_diag_port_eq_tx_table(struct switchtec_dev *dev, int port_id,
1278  enum switchtec_diag_link link,
1279  struct switchtec_port_eq_table *res);
1280 int switchtec_diag_port_eq_tx_fslf(struct switchtec_dev *dev, int port_id,
1281  int lane_id, enum switchtec_diag_end end,
1282  enum switchtec_diag_link link,
1283  struct switchtec_port_eq_tx_fslf *res);
1284 
1285 int switchtec_diag_perm_table(struct switchtec_dev *dev,
1286  struct switchtec_mrpc table[MRPC_MAX_ID]);
1287 int switchtec_diag_refclk_ctl(struct switchtec_dev *dev, int stack_id, bool en);
1288 int switchtec_diag_ltssm_log(struct switchtec_dev *dev,
1289  int port, int *log_count,
1290  struct switchtec_diag_ltssm_log *log_data);
1291 
1292 #ifdef __cplusplus
1293 }
1294 #endif
1295 
1296 #endif
switchtec_diag_cross_hair_get
int switchtec_diag_cross_hair_get(struct switchtec_dev *dev, int start_lane_id, int num_lanes, struct switchtec_diag_cross_hair *res)
Disable active cross hair.
Definition: diag.c:87
switchtec_get_fw_version
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
switchtec_gas_map
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:255
switchtec_bwcntr_res::ingress
struct switchtec_bwcntr_res::switchtec_bwcntr_dir ingress
Bandwidth into the port.
switchtec_bwcntr_many
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
switchtec_bwcntr_res::switchtec_bwcntr_dir
Definition: switchtec.h:1036
switchtec_evcntr_get_setup
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
POISONED_TLP_ERR
@ POISONED_TLP_ERR
Poisoned TLP Error.
Definition: switchtec.h:945
BAD_TLP
@ BAD_TLP
Bad TLP.
Definition: switchtec.h:953
switchtec_port_id::partition
unsigned char partition
Partition the port is in.
Definition: switchtec.h:169
switchtec_rcvr_obj
Definition: switchtec.h:1142
ping_dev_info
Definition: switchtec.h:207
switchtec_status
Port status structure.
Definition: switchtec.h:184
switchtec_event_check
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:297
switchtec_get_devices
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:194
switchtec_open_eth
struct switchtec_dev * switchtec_open_eth(const char *ip, const int inst)
Open a switchtec device over ethernet.
Definition: linux-eth.c:603
switchtec_bwcntr_res::switchtec_bwcntr_dir::nonposted
uint64_t nonposted
Non-Posted TLP bytes.
Definition: switchtec.h:1039
switchtec_is_psx
static int switchtec_is_psx(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX.
Definition: switchtec.h:533
switchtec_fw_write_file
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:366
switchtec_fw_image_info::image_crc
unsigned long image_crc
CRC checksum of the image.
Definition: switchtec.h:294
switchtec_event_summary::local_part
unsigned local_part
Bitmap of events in the local partition.
Definition: switchtec.h:325
switchtec_is_pfx
static int switchtec_is_pfx(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX.
Definition: switchtec.h:490
switchtec_event_special
switchtec_event_special
Special event indexes numbers.
Definition: switchtec.h:810
switchtec_fw_version_to_gen
enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version)
Extract generation information from FW version number.
Definition: fw.c:338
switchtec_log_parse_type
switchtec_log_parse_type
Log types to parse.
Definition: switchtec.h:243
switchtec_get_device_info
int switchtec_get_device_info(struct switchtec_dev *dev, enum switchtec_boot_phase *phase, enum switchtec_gen *gen, enum switchtec_rev *rev, struct ping_dev_info *ping_info)
Get device generation, revision, and boot phase info.
Definition: switchtec.c:1802
switchtec_event_type
switchtec_event_type
There are three event types indicated by this enumeration: global, partition and port function.
Definition: switchtec.h:819
switchtec_bwcntr_res::switchtec_bwcntr_dir::posted
uint64_t posted
Posted TLP bytes.
Definition: switchtec.h:1037
switchtec_event_wait_for
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:369
CMPLTR_ABORT_ERR
@ CMPLTR_ABORT_ERR
Completer Abort Error.
Definition: switchtec.h:944
switchtec_diag_pattern_inject
int switchtec_diag_pattern_inject(struct switchtec_dev *dev, int port_id, unsigned int err_cnt)
Inject error into pattern generator.
Definition: diag.c:551
switchtec_status::neg_lnk_width
unsigned char neg_lnk_width
Negotiated link width.
Definition: switchtec.h:187
switchtec_diag_port_eq_tx_fslf
int switchtec_diag_port_eq_tx_fslf(struct switchtec_dev *dev, int port_id, int lane_id, enum switchtec_diag_end end, enum switchtec_diag_link link, struct switchtec_port_eq_tx_fslf *res)
Get the equalization FS/LF.
Definition: diag.c:755
stmfd_rcvry_reason
stmfd_rcvry_reason
Device boot recovery reason.
Definition: switchtec.h:127
switchtec_port_id::upstream
unsigned char upstream
1 if this is an upstream port
Definition: switchtec.h:172
switchtec_status_free
void switchtec_status_free(struct switchtec_status *status, int ports)
Free a list of status structures allocated by switchtec_status()
Definition: switchtec.c:576
ECRC_ERR
@ ECRC_ERR
ECRC Error.
Definition: switchtec.h:941
switchtec_port_eq_coeff
Definition: switchtec.h:1151
switchtec_rcvr_ext
Definition: switchtec.h:1180
switchtec_open_i2c
struct switchtec_dev * switchtec_open_i2c(const char *path, int i2c_addr)
Open a switchtec device behind an I2C device.
Definition: linux-i2c.c:647
switchtec_port_to_pff
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:228
switchtec_is_psx_all
static int switchtec_is_psx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX(A).
Definition: switchtec.h:549
switchtec_status::ltssm
uint16_t ltssm
Link state.
Definition: switchtec.h:190
switchtec_partition
_PURE int switchtec_partition(struct switchtec_dev *dev)
Get the partiton number of the device that was opened.
Definition: switchtec.c:401
switchtec_status::pci_bdf_path
char * pci_bdf_path
PCI BDF path of the port.
Definition: switchtec.h:198
RCVR_ERR
@ RCVR_ERR
Receiver Error.
Definition: switchtec.h:954
switchtec_event_summary::pff
unsigned pff[SWITCHTEC_MAX_PFF_CSR]
Bitmap of events in each port function.
Definition: switchtec.h:331
switchtec_name
const _PURE char * switchtec_name(struct switchtec_dev *dev)
Get the string that was used to open the deviec.
Definition: switchtec.c:391
switchtec_event_summary
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:297
switchtec_status::ltssm_str
const char * ltssm_str
Link state as a string.
Definition: switchtec.h:191
switchtec_open_by_pci_addr
struct switchtec_dev * switchtec_open_by_pci_addr(int domain, int bus, int device, int func)
Open a switchtec device by PCI address (BDF)
Definition: linux.c:1050
switchtec_diag_eye_fetch
int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels, size_t pixel_cnt, int *lane_id)
Start a PCIe Eye Capture.
Definition: diag.c:246
switchtec_diag_pattern_gen_get
int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern *type)
Get Pattern Generator set on port.
Definition: diag.c:462
switchtec_fw_img_write_hdr
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:1498
switchtec_diag_eye_cancel
int switchtec_diag_eye_cancel(struct switchtec_dev *dev)
Cancel in-progress eye capture.
Definition: diag.c:306
switchtec_stack_bif_port_valid
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:2148
switchtec_bwcntr_res::egress
struct switchtec_bwcntr_res::switchtec_bwcntr_dir egress
Bandwidth out of the port.
switchtec_status::lane_reversal_str
const char * lane_reversal_str
Lane reversal as a string.
Definition: switchtec.h:193
MALFORM_TLP_ERR
@ MALFORM_TLP_ERR
Malformed TLP Error.
Definition: switchtec.h:942
switchtec_pff_to_port
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:213
switchtec_calc_port_lane
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:2037
switchtec_fw_image_info::image_len
size_t image_len
Length of the image.
Definition: switchtec.h:293
switchtec_bw_type
switchtec_bw_type
The types of bandwidth.
Definition: switchtec.h:220
switchtec_max_supported_ports
static int switchtec_max_supported_ports(struct switchtec_dev *dev)
Return the max number of ports of a Switchtec device.
Definition: switchtec.h:481
switchtec_device_info::name
char name[256]
Device name, eg. switchtec0.
Definition: switchtec.h:156
switchtec_is_psx_pfx_all
static int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX or PSX.
Definition: switchtec.h:558
switchtec_close
void switchtec_close(struct switchtec_dev *dev)
Close a Switchtec device handle.
Definition: platform.c:101
switchtec_status
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:491
RCV_NON_FATAL_MSG
@ RCV_NON_FATAL_MSG
Receive Non-FATAL Error Message.
Definition: switchtec.h:956
switchtec_fw_toggle_active_partition
int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev, int toggle_bl2, int toggle_key, int toggle_fw, int toggle_cfg)
Toggle the active firmware partition for the main or configuration images.
Definition: fw.c:193
switchtec_diag_perm_table
int switchtec_diag_perm_table(struct switchtec_dev *dev, struct switchtec_mrpc table[MRPC_MAX_ID])
Get the permission table.
Definition: diag.c:862
switchtec_evcntr_type_count
int switchtec_evcntr_type_count(void)
Get the number of event counter types.
Definition: pmon.c:95
switchtec_evcntr_setup::threshold
unsigned threshold
Threshold to count to before generating an interrupt.
Definition: switchtec.h:1009
switchtec_bwcntr_res::switchtec_bwcntr_dir::comp
uint64_t comp
Completion TLP bytes.
Definition: switchtec.h:1038
switchtec_gen_datarate
static const float switchtec_gen_datarate[]
Number of GB/s capable for each PCI generation or link_rate.
Definition: switchtec.h:681
POSTED_TLP
@ POSTED_TLP
Posted TLP.
Definition: switchtec.h:960
switchtec_diag_pattern_mon_set
int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern type)
Setup Pattern Monitor.
Definition: diag.c:491
switchtec_stack_bif_width
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:2164
switchtec_is_gen3
static int switchtec_is_gen3(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 3 device.
Definition: switchtec.h:457
switchtec_status::port
struct switchtec_port_id port
Port ID.
Definition: switchtec.h:185
switchtec_is_psxa
static int switchtec_is_psxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX-A.
Definition: switchtec.h:541
switchtec_gen_transfers
static const float switchtec_gen_transfers[]
Number of GT/s capable for each PCI generation or link_rate.
Definition: switchtec.h:679
switchtec_variant_str
static const char * switchtec_variant_str(struct switchtec_dev *dev)
Return the variant string of a Switchtec device.
Definition: switchtec.h:644
switchtec_status::device_id
int device_id
Device ID.
Definition: switchtec.h:202
switchtec_fw_image_info::gen
enum switchtec_gen gen
Image generation.
Definition: switchtec.h:286
COMP_TLP
@ COMP_TLP
Completion TLP.
Definition: switchtec.h:961
UNCOR_INT_ERR
@ UNCOR_INT_ERR
Uncorrectable Internal Error.
Definition: switchtec.h:949
switchtec_fw_image_info
Information about a firmware image or partition.
Definition: switchtec.h:285
switchtec_is_pax
static int switchtec_is_pax(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX.
Definition: switchtec.h:566
switchtec_port_id::log_id
unsigned char log_id
Logical port number.
Definition: switchtec.h:175
switchtec_event_summary_test
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:219
switchtec_boot_phase
switchtec_boot_phase
Device boot phase.
Definition: switchtec.h:117
switchtec_fw_write_fd
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:246
switchtec_device_info::product_rev
char product_rev[8]
Product revision.
Definition: switchtec.h:160
switchtec_port_id
Port identification.
Definition: switchtec.h:168
REPLAY_NUM_ROLLOVER
@ REPLAY_NUM_ROLLOVER
Replay Number Rollover.
Definition: switchtec.h:951
switchtec_diag_pattern_gen_set
int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id, enum switchtec_diag_pattern type)
Setup Pattern Generator.
Definition: diag.c:442
switchtec_fw_perror
void switchtec_fw_perror(const char *s, int ret)
Print an error string to stdout.
Definition: fw.c:462
switchtec_log_def_type
switchtec_log_def_type
Log definition data types.
Definition: switchtec.h:265
RCV_CORR_MSG
@ RCV_CORR_MSG
Receive Correctable Error Message.
Definition: switchtec.h:957
switchtec_variant
switchtec_variant
The variant types of Switchtec device.
Definition: switchtec.h:140
switchtec_evcntr_type_str
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
switchtec_lat_setup
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
switchtec_fw_image_info::part_id
unsigned long part_id
Image partition ID.
Definition: switchtec.h:287
switchtec_evcntr_setup::type_mask
enum switchtec_evcntr_type_mask type_mask
Event counter types to count.
Definition: switchtec.h:1002
switchtec_fw_part_summary::switchtec_fw_part_type
Definition: switchtec.h:309
switchtec_diag_port_eq_tx_coeff
int switchtec_diag_port_eq_tx_coeff(struct switchtec_dev *dev, int port_id, enum switchtec_diag_end end, enum switchtec_diag_link link, struct switchtec_port_eq_coeff *res)
Get the port equalization TX coefficients.
Definition: diag.c:633
switchtec_hard_reset
int switchtec_hard_reset(struct switchtec_dev *dev)
Perform an MRPC hard reset command.
Definition: switchtec.c:834
switchtec_event_id
switchtec_event_id
Enumeration of all possible events.
Definition: switchtec.h:337
switchtec_strerror
const char * switchtec_strerror(void)
Return a message coresponding to the last error.
Definition: switchtec.c:615
switchtec_phase_id_str
static const char * switchtec_phase_id_str(enum switchtec_boot_phase phase_id)
Return the phase string for a phase id.
Definition: switchtec.h:663
switchtec_fw_dlstatus
switchtec_fw_dlstatus
Firmware update status.
Definition: switchtec.h:848
switchtec_event_info
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:343
switchtec_is_gen4
static int switchtec_is_gen4(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 4 device.
Definition: switchtec.h:465
NON_POSTED_TLP
@ NON_POSTED_TLP
Non-Posted TLP.
Definition: switchtec.h:962
switchtec_list
int switchtec_list(struct switchtec_device_info **devlist)
List all the switchtec devices in the system.
Definition: linux.c:213
BAD_DLLP
@ BAD_DLLP
Bad DLLP.
Definition: switchtec.h:952
stmfd_rev_str
static const char * stmfd_rev_str(uint8_t rev)
Return the revision string for Stamford Platform.
Definition: switchtec.h:604
NAK_RCVD
@ NAK_RCVD
NAK Received.
Definition: switchtec.h:958
switchtec_set_stack_bif
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:2233
switchtec_fw_read_fd
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:1390
ALL_ERRORS
@ ALL_ERRORS
Mask indicating all possible errors.
Definition: switchtec.h:967
switchtec_fw_image_info::version
char version[32]
Firmware/Config version.
Definition: switchtec.h:289
switchtec_bwcntr_res
Bandwidth counter result struct.
Definition: switchtec.h:1034
switchtec_diag_loopback_set
int switchtec_diag_loopback_set(struct switchtec_dev *dev, int port_id, int enable, enum switchtec_diag_ltssm_speed ltssm_speed)
Setup Loopback Mode.
Definition: diag.c:334
switchtec_fw_image_info::part_body_offset
size_t part_body_offset
Partition image body offset.
Definition: switchtec.h:292
switchtec_mrpc
Definition: switchtec.h:1187
switchtec_parse_log
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:1586
switchtec_diag_pattern_mon_get
int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id, int lane_id, enum switchtec_diag_pattern *type, unsigned long long *err_cnt)
Get Pattern Monitor.
Definition: diag.c:512
switchtec_open_by_index
struct switchtec_dev * switchtec_open_by_index(int index)
Open a switchtec device by index.
Definition: linux.c:1035
switchtec_fw_is_boot_ro
int switchtec_fw_is_boot_ro(struct switchtec_dev *dev)
Check if the boot partition is marked as read-only.
Definition: fw.c:1523
switchtec_open_uart
struct switchtec_dev * switchtec_open_uart(int fd)
Open a switchtec device behind a uart device.
Definition: linux-uart.c:497
switchtec_is_pfxa
static int switchtec_is_pfxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-A.
Definition: switchtec.h:514
switchtec_bwcntr_sub
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
switchtec_device_info::product_id
char product_id[32]
Product ID.
Definition: switchtec.h:159
switchtec_lat_get
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
switchtec_die_temp
float switchtec_die_temp(struct switchtec_dev *dev)
Get the die temperature of the switchtec device.
Definition: switchtec.c:1887
switchtec_fw_file_info
int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info)
Retrieve information about a firmware image file.
Definition: fw.c:687
switchtec_fw_body_read_fd
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:1439
switchtec_is_paxa
static int switchtec_is_paxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX-A.
Definition: switchtec.h:574
switchtec_evcntr_get_both
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
switchtec_gas_unmap
void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map)
Unmap the GAS region mapped with.
Definition: platform.c:267
switchtec_status::pci_bdf
char * pci_bdf
PCI BDF of the port.
Definition: switchtec.h:197
range
Definition: utils.h:34
switchtec_event_summary::part
unsigned part[SWITCHTEC_MAX_PARTS]
Bitmap of events in each partition.
Definition: switchtec.h:328
switchtec_fw_file_secure_version_newer
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:720
switchtec_event_flags
switchtec_event_flags
Event control flags.
Definition: switchtec.h:791
switchtec_event_summary
Event summary bitmaps.
Definition: switchtec.h:322
switchtec_fw_image_info::part_len
size_t part_len
Length of the partition.
Definition: switchtec.h:291
switchtec_fw_ro
switchtec_fw_ro
Flag which indicates if a partition is read-only or not.
Definition: switchtec.h:882
switchtec_status::vendor_id
int vendor_id
Vendor ID.
Definition: switchtec.h:201
switchtec_device_info::path
char path[PATH_MAX]
Path to the device.
Definition: switchtec.h:162
switchtec_calc_lane_mask
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:2101
switchtec_log_file_info
Information about log file and log definition file.
Definition: switchtec.h:251
SURPRISE_DOWN_ERR
@ SURPRISE_DOWN_ERR
Surprise Down Error.
Definition: switchtec.h:946
switchtec_fw_part_summary
struct switchtec_fw_part_summary * switchtec_fw_part_summary(struct switchtec_dev *dev)
Return firmware summary information structure for the flash partitfons in the device.
Definition: fw.c:1243
switchtec_event_summary_set
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:175
switchtec_diag_loopback_get
int switchtec_diag_loopback_get(struct switchtec_dev *dev, int port_id, int *enabled, enum switchtec_diag_ltssm_speed *ltssm_speed)
Setup Loopback Mode.
Definition: diag.c:384
switchtec_fw_part_summary_free
void switchtec_fw_part_summary_free(struct switchtec_fw_part_summary *summary)
Free a firmware part summary data structure.
Definition: fw.c:1328
switchtec_evcntr_setup
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
switchtec_bwcntr_all
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
switchtec_evcntr_type_mask
switchtec_evcntr_type_mask
Event counter type mask (may be or-d together)
Definition: switchtec.h:939
switchtec_bind_status_out
Definition: bind.h:48
HDR_LOG_OFLOW_ERR
@ HDR_LOG_OFLOW_ERR
Header Log Overflow Error.
Definition: switchtec.h:948
switchtec_diag_eye_set_mode
int switchtec_diag_eye_set_mode(struct switchtec_dev *dev, enum switchtec_diag_eye_data_mode mode)
Set the data mode for the next Eye Capture.
Definition: diag.c:168
switchtec_diag_ltssm_log
Definition: switchtec.h:1231
switchtec_open
struct switchtec_dev * switchtec_open(const char *device)
Open a Switchtec device by string.
Definition: switchtec.c:258
gasptr_t
__gas struct switchtec_gas * gasptr_t
Shortform for a pointer to the GAS register space.
Definition: switchtec.h:83
switchtec_fw_read
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:1346
switchtec_evcntr_get
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
ALL_TLPS
@ ALL_TLPS
Mask indicating all TLP types.
Definition: switchtec.h:977
UNSUP_REQ_ERR
@ UNSUP_REQ_ERR
Unsupported Request Error.
Definition: switchtec.h:940
switchtec_port_id::stk_id
unsigned char stk_id
Port number within the stack.
Definition: switchtec.h:173
switchtec_bwcntr_set_all
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
switchtec_status::first_act_lane
unsigned char first_act_lane
First active lane.
Definition: switchtec.h:194
switchtec_rev
switchtec_rev
Device hardware revision.
Definition: switchtec.h:107
switchtec_device_info::fw_version
char fw_version[32]
Firmware version.
Definition: switchtec.h:161
switchtec_fw_image_type
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:772
switchtec_diag_cross_hair
Definition: switchtec.h:1119
switchtec_event_summary::part_bitmap
uint64_t part_bitmap
Bitmap of partitions with active events.
Definition: switchtec.h:324
DATA_LINK_PROTO_ERR
@ DATA_LINK_PROTO_ERR
Data Link Protocol Error.
Definition: switchtec.h:947
switchtec_event_wait
int switchtec_event_wait(struct switchtec_dev *dev, int timeout_ms)
Wait for any event to occur (typically just an interrupt)
Definition: platform.c:329
switchtec_diag_rcvr_obj
int switchtec_diag_rcvr_obj(struct switchtec_dev *dev, int port_id, int lane_id, enum switchtec_diag_link link, struct switchtec_rcvr_obj *res)
Get the receiver object.
Definition: diag.c:578
switchtec_is_pfx_all
static int switchtec_is_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX(L/I/A).
Definition: switchtec.h:522
switchtec_fw_image_info::type
enum switchtec_fw_type type
Image partition type.
Definition: switchtec.h:288
switchtec_status::lane_reversal
unsigned char lane_reversal
Lane reversal.
Definition: switchtec.h:192
switchtec_log_to_file
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:1505
switchtec_status::acs_ctrl
unsigned int acs_ctrl
ACS Setting of the Port.
Definition: switchtec.h:204
switchtec_evcntr_setup
Structure used to setup an event counter.
Definition: switchtec.h:998
switchtec_log_type
switchtec_log_type
Describe the type of logs too dump.
Definition: switchtec.h:229
switchtec_status::link_up
unsigned char link_up
1 if the link is up
Definition: switchtec.h:188
switchtec_lat_setup_many
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
switchtec_status::cfg_lnk_width
unsigned char cfg_lnk_width
Configured link width.
Definition: switchtec.h:186
switchtec_diag_ltssm_log
int switchtec_diag_ltssm_log(struct switchtec_dev *dev, int port, int *log_count, struct switchtec_diag_ltssm_log *log_data)
Get the LTSSM log of a port on a switchtec device.
Definition: diag.c:917
switchtec_get_stack_bif
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:2189
REPLAY_TMR_TIMEOUT
@ REPLAY_TMR_TIMEOUT
Replay Timer Timeout.
Definition: switchtec.h:950
stmfd_rev
stmfd_rev
Device hardware revision for Stamford Platform.
Definition: switchtec.h:99
switchtec_lat_get_many
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
switchtec_status::pci_dev
char * pci_dev
PCI BDF of the device on the port.
Definition: switchtec.h:200
switchtec_fw_set_boot_ro
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:1562
switchtec_gas
Definition: registers.h:377
switchtec_device_info::desc
char desc[256]
Device description, if available.
Definition: switchtec.h:157
switchtec_open_by_path
struct switchtec_dev * switchtec_open_by_path(const char *path)
Open a switchtec device by path.
Definition: linux.c:999
switchtec_diag_refclk_ctl
int switchtec_diag_refclk_ctl(struct switchtec_dev *dev, int stack_id, bool en)
Control the refclk output for a stack.
Definition: diag.c:899
switchtec_device_info
Represents a Switchtec device in the switchtec_list() function.
Definition: switchtec.h:155
switchtec_gen
switchtec_gen
The PCIe generations.
Definition: switchtec.h:89
switchtec_status::class_devices
char * class_devices
Comma seperated list of classes.
Definition: switchtec.h:203
switchtec_diag_cross_hair_disable
int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev)
Disable active cross hair.
Definition: diag.c:69
switchtec_port_id::phys_id
unsigned char phys_id
Physical port number.
Definition: switchtec.h:174
switchtec_status::link_rate
unsigned char link_rate
Link rate/gen.
Definition: switchtec.h:189
switchtec_is_gen5
static int switchtec_is_gen5(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 5 device.
Definition: switchtec.h:473
RCVR_OFLOW_ERR
@ RCVR_OFLOW_ERR
Receiver Overflow Error.
Definition: switchtec.h:943
switchtec_port_eq_tx_fslf
Definition: switchtec.h:1175
switchtec_device_info::pci_dev
char pci_dev[256]
PCI BDF string.
Definition: switchtec.h:158
switchtec_bwcntr_res::time_us
uint64_t time_us
Time (in microseconds)
Definition: switchtec.h:1035
switchtec_fw_image_gen_str
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:631
switchtec_perror
void switchtec_perror(const char *str)
Print an error string to stdout.
Definition: switchtec.c:787
switchtec_event_summary_iter
int switchtec_event_summary_iter(struct switchtec_event_summary *sum, enum switchtec_event_id *e, int *idx)
Iterate through all set bits in an event summary structure.
Definition: events.c:248
switchtec_echo
int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output)
Perform an MRPC echo command.
Definition: switchtec.c:818
switchtec_diag_rcvr_ext
int switchtec_diag_rcvr_ext(struct switchtec_dev *dev, int port_id, int lane_id, enum switchtec_diag_link link, struct switchtec_rcvr_ext *res)
Get the Extended Receiver Object.
Definition: diag.c:817
switchtec_log_def_to_file
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:1698
switchtec_is_pfxl
static int switchtec_is_pfxl(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-L.
Definition: switchtec.h:498
switchtec_evcntr_wait
int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms)
Block until any event counter has reached its threshold.
Definition: pmon.c:325
switchtec_evcntr_type_list
Null-terminated list of all event counter types with a name and help text.
Definition: switchtec.h:989
switchtec_fw_part_summary
Definition: switchtec.h:308
switchtec_port_eq_table
Definition: switchtec.h:1159
RCV_FATAL_MSG
@ RCV_FATAL_MSG
Receive FATAL Error Message.
Definition: switchtec.h:955
switchtec_diag_cross_hair_enable
int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id)
Enable cross hair on specified lane.
Definition: diag.c:52
switchtec_rev_str
static const char * switchtec_rev_str(enum switchtec_rev rev)
Return the revision string.
Definition: switchtec.h:616
switchtec_calc_lane_id
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:1997
RULE_TABLE_HIT
@ RULE_TABLE_HIT
Rule Search Table Rule Hit.
Definition: switchtec.h:959
ALL
@ ALL
Mask indicating all event types.
Definition: switchtec.h:982
switchtec_diag_eye_start
int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4], struct range *x_range, struct range *y_range, int step_interval)
Start a PCIe Eye Capture.
Definition: diag.c:191
switchtec_fw_image_info::part_addr
size_t part_addr
Address of the partition.
Definition: switchtec.h:290
switchtec_gen_str
static const char * switchtec_gen_str(struct switchtec_dev *dev)
Return the generation string of a Switchtec device.
Definition: switchtec.h:590
switchtec_cmd
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:164
switchtec_device_id
_PURE int switchtec_device_id(struct switchtec_dev *dev)
Get the device id of the device.
Definition: switchtec.c:343
switchtec_port_id::stack
unsigned char stack
Stack number.
Definition: switchtec.h:171
switchtec_diag_port_eq_tx_table
int switchtec_diag_port_eq_tx_table(struct switchtec_dev *dev, int port_id, enum switchtec_diag_link link, struct switchtec_port_eq_table *res)
Get the far end TX equalization table.
Definition: diag.c:695
switchtec_event_ctl
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:313
switchtec_is_pax_all
static int switchtec_is_pax_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX(A).
Definition: switchtec.h:582
switchtec_event_summary::global
uint64_t global
Bitmap of global events.
Definition: switchtec.h:323
switchtec_bwcntr_tot
uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d)
Get the total.
Definition: pmon.c:513
switchtec_list_free
void switchtec_list_free(struct switchtec_device_info *devlist)
Free a list of device info structures allocated by switchtec_list()
Definition: switchtec.c:236
switchtec_is_pfxi
static int switchtec_is_pfxi(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-I.
Definition: switchtec.h:506
switchtec_bwcntr_set_many
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