Switchtec Userspace  PROJECT_NUMBER = 3.1
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 #ifdef __CHECKER__
70 #define __gas __attribute__((noderef, address_space(1)))
71 #else
72 #define __gas
73 #endif
74 
75 #define _PURE __attribute__ ((pure))
76 
80 typedef __gas struct switchtec_gas *gasptr_t;
81 #define SWITCHTEC_MAP_FAILED ((gasptr_t) -1)
82 
87  SWITCHTEC_GEN3,
88  SWITCHTEC_GEN4,
89  SWITCHTEC_GEN5,
90  SWITCHTEC_GEN_UNKNOWN,
91 };
92 
97  SWITCHTEC_REVA = 0x0f,
98  SWITCHTEC_REVB = 0x00,
99  SWITCHTEC_REVC = 0x01,
100  SWITCHTEC_REV_UNKNOWN = 0xff
101 };
102 
107  SWITCHTEC_BOOT_PHASE_BL1 = 1,
108  SWITCHTEC_BOOT_PHASE_BL2,
109  SWITCHTEC_BOOT_PHASE_FW,
110  SWITCHTEC_BOOT_PHASE_UNKNOWN
111 };
112 
117  SWITCHTEC_PFX,
118  SWITCHTEC_PFXL,
119  SWITCHTEC_PFXI,
120  SWITCHTEC_PSX,
121  SWITCHTEC_PAX,
122  SWITCHTEC_PAXA,
123  SWITCHTEC_PFXA,
124  SWITCHTEC_PSXA,
125  SWITCHTEC_VAR_UNKNOWN,
126 };
127 
132  char name[256];
133  char desc[256];
134  char pci_dev[256];
135  char product_id[32];
136  char product_rev[8];
137  char fw_version[32];
138  char path[PATH_MAX];
139 };
140 
145  unsigned char partition;
146 
147  unsigned char stack;
148  unsigned char upstream;
149  unsigned char stk_id;
150  unsigned char phys_id;
151  unsigned char log_id;
152 };
153 
162  unsigned char cfg_lnk_width;
163  unsigned char neg_lnk_width;
164  unsigned char link_up;
165  unsigned char link_rate;
166  uint16_t ltssm;
167  const char *ltssm_str;
168  unsigned char lane_reversal;
169  const char *lane_reversal_str;
170  unsigned char first_act_lane;
171  char lanes[17];
172 
173  char *pci_bdf;
174  char *pci_bdf_path;
175 
176  char *pci_dev;
177  int vendor_id;
178  int device_id;
180  unsigned int acs_ctrl;
181 };
182 
187  SWITCHTEC_BW_TYPE_RAW = 0x0,
188  SWITCHTEC_BW_TYPE_PAYLOAD = 0x1,
189 };
190 
196  SWITCHTEC_LOG_RAM,
197  SWITCHTEC_LOG_FLASH,
198  SWITCHTEC_LOG_MEMLOG,
199  SWITCHTEC_LOG_REGS,
200  SWITCHTEC_LOG_SYS_STACK,
201  SWITCHTEC_LOG_THRD_STACK,
202  SWITCHTEC_LOG_THRD,
203  SWITCHTEC_LOG_NVHDR,
204 };
205 
210  SWITCHTEC_LOG_PARSE_TYPE_APP,
211  SWITCHTEC_LOG_PARSE_TYPE_MAILBOX
212 };
213 
218  unsigned int log_fw_version;
219  unsigned int log_sdk_version;
220  unsigned int def_fw_version;
221  unsigned int def_sdk_version;
222  bool version_mismatch;
223  bool overflow;
224  bool gen_unknown;
225  bool gen_ignored;
226 };
227 
232  SWITCHTEC_LOG_DEF_TYPE_APP,
233  SWITCHTEC_LOG_DEF_TYPE_MAILBOX
234 };
235 
236 enum switchtec_fw_type {
237  SWITCHTEC_FW_TYPE_UNKNOWN = 0,
238  SWITCHTEC_FW_TYPE_BOOT,
239  SWITCHTEC_FW_TYPE_MAP,
240  SWITCHTEC_FW_TYPE_IMG,
241  SWITCHTEC_FW_TYPE_CFG,
242  SWITCHTEC_FW_TYPE_NVLOG,
243  SWITCHTEC_FW_TYPE_SEEPROM,
244  SWITCHTEC_FW_TYPE_KEY,
245  SWITCHTEC_FW_TYPE_BL2,
246 };
247 
253  unsigned long part_id;
254  enum switchtec_fw_type type;
255  char version[32];
256  size_t part_addr;
257  size_t part_len;
259  size_t image_len;
260  unsigned long image_crc;
261 
262  bool valid;
263  bool active;
264  bool running;
265  bool read_only;
266  bool redundant;
267 
268  struct switchtec_fw_image_info *next;
269  void *metadata;
270 
271  unsigned long secure_version;
272  bool signed_image;
273 };
274 
277  struct switchtec_fw_image_info *active, *inactive;
278  } boot, map, img, cfg, nvlog, seeprom, key, bl2;
279 
280  struct switchtec_fw_image_info *mult_cfg;
281 
282  int nr_info;
283  struct switchtec_fw_image_info all[];
284 };
285 
290  uint64_t global;
291  uint64_t part_bitmap;
292  unsigned local_part;
293 
295  unsigned part[SWITCHTEC_MAX_PARTS];
296 
298  unsigned pff[SWITCHTEC_MAX_PFF_CSR];
299 };
300 
305  SWITCHTEC_EVT_INVALID = -1,
306  SWITCHTEC_GLOBAL_EVT_STACK_ERROR,
307  SWITCHTEC_GLOBAL_EVT_PPU_ERROR,
308  SWITCHTEC_GLOBAL_EVT_ISP_ERROR,
309  SWITCHTEC_GLOBAL_EVT_SYS_RESET,
310  SWITCHTEC_GLOBAL_EVT_FW_EXC,
311  SWITCHTEC_GLOBAL_EVT_FW_NMI,
312  SWITCHTEC_GLOBAL_EVT_FW_NON_FATAL,
313  SWITCHTEC_GLOBAL_EVT_FW_FATAL,
314  SWITCHTEC_GLOBAL_EVT_TWI_MRPC_COMP,
315  SWITCHTEC_GLOBAL_EVT_TWI_MRPC_COMP_ASYNC,
316  SWITCHTEC_GLOBAL_EVT_CLI_MRPC_COMP,
317  SWITCHTEC_GLOBAL_EVT_CLI_MRPC_COMP_ASYNC,
318  SWITCHTEC_GLOBAL_EVT_GPIO_INT,
319  SWITCHTEC_GLOBAL_EVT_GFMS,
320  SWITCHTEC_PART_EVT_PART_RESET,
321  SWITCHTEC_PART_EVT_MRPC_COMP,
322  SWITCHTEC_PART_EVT_MRPC_COMP_ASYNC,
323  SWITCHTEC_PART_EVT_DYN_PART_BIND_COMP,
324  SWITCHTEC_PFF_EVT_AER_IN_P2P,
325  SWITCHTEC_PFF_EVT_AER_IN_VEP,
326  SWITCHTEC_PFF_EVT_DPC,
327  SWITCHTEC_PFF_EVT_CTS,
328  SWITCHTEC_PFF_EVT_UEC,
329  SWITCHTEC_PFF_EVT_HOTPLUG,
330  SWITCHTEC_PFF_EVT_IER,
331  SWITCHTEC_PFF_EVT_THRESH,
332  SWITCHTEC_PFF_EVT_POWER_MGMT,
333  SWITCHTEC_PFF_EVT_TLP_THROTTLING,
334  SWITCHTEC_PFF_EVT_FORCE_SPEED,
335  SWITCHTEC_PFF_EVT_CREDIT_TIMEOUT,
336  SWITCHTEC_PFF_EVT_LINK_STATE,
337  SWITCHTEC_MAX_EVENTS,
338 };
339 
340 /*********** Platform Functions ***********/
341 
342 struct switchtec_dev *switchtec_open(const char *device);
343 struct switchtec_dev *switchtec_open_by_path(const char *path);
344 struct switchtec_dev *switchtec_open_by_index(int index);
345 struct switchtec_dev *switchtec_open_by_pci_addr(int domain, int bus,
346  int device, int func);
347 struct switchtec_dev *switchtec_open_i2c(const char *path, int i2c_addr);
348 struct switchtec_dev *switchtec_open_i2c_by_adapter(int adapter, int i2c_addr);
349 struct switchtec_dev *switchtec_open_uart(int fd);
350 struct switchtec_dev *switchtec_open_eth(const char *ip, const int inst);
351 
352 void switchtec_close(struct switchtec_dev *dev);
353 int switchtec_list(struct switchtec_device_info **devlist);
354 void switchtec_list_free(struct switchtec_device_info *devlist);
355 int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf,
356  size_t buflen);
357 int switchtec_cmd(struct switchtec_dev *dev, uint32_t cmd,
358  const void *payload, size_t payload_len, void *resp,
359  size_t resp_len);
360 int switchtec_get_devices(struct switchtec_dev *dev,
361  struct switchtec_status *status,
362  int ports);
363 int switchtec_pff_to_port(struct switchtec_dev *dev, int pff,
364  int *partition, int *port);
365 int switchtec_port_to_pff(struct switchtec_dev *dev, int partition,
366  int port, int *pff);
367 int switchtec_event_summary(struct switchtec_dev *dev,
368  struct switchtec_event_summary *sum);
369 int switchtec_event_check(struct switchtec_dev *dev,
370  struct switchtec_event_summary *check,
371  struct switchtec_event_summary *res);
372 int switchtec_event_ctl(struct switchtec_dev *dev,
373  enum switchtec_event_id e,
374  int index, int flags,
375  uint32_t data[5]);
376 int switchtec_event_wait(struct switchtec_dev *dev, int timeout_ms);
377 
378 /*********** Generic Accessors ***********/
379 
380 _PURE const char *switchtec_name(struct switchtec_dev *dev);
381 _PURE int switchtec_partition(struct switchtec_dev *dev);
382 _PURE int switchtec_device_id(struct switchtec_dev *dev);
383 _PURE enum switchtec_gen switchtec_gen(struct switchtec_dev *dev);
384 _PURE enum switchtec_variant switchtec_variant(struct switchtec_dev *dev);
385 _PURE enum switchtec_boot_phase
386 switchtec_boot_phase(struct switchtec_dev *dev);
387 int switchtec_set_pax_id(struct switchtec_dev *dev, int pax_id);
388 int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output);
389 int switchtec_hard_reset(struct switchtec_dev *dev);
390 int switchtec_status(struct switchtec_dev *dev,
391  struct switchtec_status **status);
392 void switchtec_status_free(struct switchtec_status *status, int ports);
393 int switchtec_get_device_info(struct switchtec_dev *dev,
394  enum switchtec_boot_phase *phase,
395  enum switchtec_gen *gen,
396  enum switchtec_rev *rev);
397 const char *switchtec_strerror(void);
398 void switchtec_perror(const char *str);
399 int switchtec_log_to_file(struct switchtec_dev *dev,
400  enum switchtec_log_type type, int fd, FILE *log_def_file,
401  struct switchtec_log_file_info *info);
402 int switchtec_parse_log(FILE *bin_log_file, FILE *log_def_file,
403  FILE *parsed_log_file,
404  enum switchtec_log_parse_type log_type,
405  enum switchtec_gen gen,
406  struct switchtec_log_file_info *info);
407 int switchtec_log_def_to_file(struct switchtec_dev *dev,
408  enum switchtec_log_def_type type,
409  FILE* file);
410 float switchtec_die_temp(struct switchtec_dev *dev);
411 int switchtec_calc_lane_id(struct switchtec_dev *dev, int phys_port_id,
412  int lane_id, struct switchtec_status *port);
413 int switchtec_calc_port_lane(struct switchtec_dev *dev, int lane_id,
414  int *phys_port_id, int *port_lane_id,
415  struct switchtec_status *port);
416 int switchtec_calc_lane_mask(struct switchtec_dev *dev, int phys_port_id,
417  int lane_id, int num_lanes, int *lane_mask,
418  struct switchtec_status *port);
419 
423 static inline int switchtec_is_gen3(struct switchtec_dev *dev)
424 {
425  return switchtec_gen(dev) == SWITCHTEC_GEN3;
426 }
427 
431 static inline int switchtec_is_gen4(struct switchtec_dev *dev)
432 {
433  return switchtec_gen(dev) == SWITCHTEC_GEN4;
434 }
435 
439 static inline int switchtec_is_gen5(struct switchtec_dev *dev)
440 {
441  return switchtec_gen(dev) == SWITCHTEC_GEN5;
442 }
443 
447 static inline int switchtec_is_pfx(struct switchtec_dev *dev)
448 {
449  return switchtec_variant(dev) == SWITCHTEC_PFX;
450 }
451 
455 static inline int switchtec_is_pfxl(struct switchtec_dev *dev)
456 {
457  return switchtec_variant(dev) == SWITCHTEC_PFXL;
458 }
459 
463 static inline int switchtec_is_pfxi(struct switchtec_dev *dev)
464 {
465  return switchtec_variant(dev) == SWITCHTEC_PFXI;
466 }
467 
471 static inline int switchtec_is_pfxa(struct switchtec_dev *dev)
472 {
473  return switchtec_variant(dev) == SWITCHTEC_PFXA;
474 }
475 
479 static inline int switchtec_is_pfx_all(struct switchtec_dev *dev)
480 {
481  return switchtec_is_pfx(dev) ||
482  switchtec_is_pfxl(dev) ||
483  switchtec_is_pfxi(dev) ||
484  switchtec_is_pfxa(dev);
485 }
486 
490 static inline int switchtec_is_psx(struct switchtec_dev *dev)
491 {
492  return switchtec_variant(dev) == SWITCHTEC_PSX;
493 }
494 
498 static inline int switchtec_is_psxa(struct switchtec_dev *dev)
499 {
500  return switchtec_variant(dev) == SWITCHTEC_PSXA;
501 }
502 
506 static inline int switchtec_is_psx_all(struct switchtec_dev *dev)
507 {
508  return switchtec_is_psx(dev) ||
509  switchtec_is_psxa(dev);
510 }
511 
515 static inline int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
516 {
517  return switchtec_is_psx_all(dev) || switchtec_is_pfx_all(dev);
518 }
519 
523 static inline int switchtec_is_pax(struct switchtec_dev *dev)
524 {
525  return switchtec_variant(dev) == SWITCHTEC_PAX;
526 }
527 
531 static inline int switchtec_is_paxa(struct switchtec_dev *dev)
532 {
533  return switchtec_variant(dev) == SWITCHTEC_PAXA;
534 }
535 
539 static inline int switchtec_is_pax_all(struct switchtec_dev *dev)
540 {
541  return switchtec_is_pax(dev) || switchtec_is_paxa(dev);
542 }
543 
547 static inline const char *switchtec_gen_str(struct switchtec_dev *dev)
548 {
549  const char *str;
550 
551  str = switchtec_is_gen3(dev) ? "GEN3" :
552  switchtec_is_gen4(dev) ? "GEN4" :
553  switchtec_is_gen5(dev) ? "GEN5" : "Unknown";
554 
555  return str;
556 }
557 
561 static inline const char *switchtec_rev_str(enum switchtec_rev rev)
562 {
563  const char *str;
564 
565  str = (rev == SWITCHTEC_REVA) ? "REVA" :
566  (rev == SWITCHTEC_REVB) ? "REVB" :
567  (rev == SWITCHTEC_REVC) ? "REVC" : "Unknown";
568 
569  return str;
570 }
571 
575 static inline const char *
577 {
578  switch (inf->gen) {
579  case SWITCHTEC_GEN3: return "GEN3";
580  case SWITCHTEC_GEN4: return "GEN4";
581  case SWITCHTEC_GEN5: return "GEN5";
582  default: return "UNKNOWN";
583  }
584 }
585 
589 static inline const char *switchtec_variant_str(struct switchtec_dev *dev)
590 {
591  const char *str;
592 
593  str = switchtec_is_pfx(dev) ? "PFX" :
594  switchtec_is_pfxl(dev) ? "PFX-L" :
595  switchtec_is_pfxi(dev) ? "PFX-I" :
596  switchtec_is_psx(dev) ? "PSX" :
597  switchtec_is_pax(dev) ? "PAX" :
598  switchtec_is_pfxa(dev) ? "PFX-A" :
599  switchtec_is_psxa(dev) ? "PSX-A" :
600  switchtec_is_paxa(dev) ? "PAX-A" : "Unknown";
601 
602  return str;
603 }
604 
606 static const float switchtec_gen_transfers[] = {0, 2.5, 5, 8, 16};
608 static const float switchtec_gen_datarate[] = {0, 250, 500, 985, 1969};
609 
610 static inline const char *switchtec_ltssm_str(int ltssm, int show_minor)
611 {
612  if (!show_minor)
613  ltssm |= 0xFF00;
614 
615  switch(ltssm) {
616  case 0x0000: return "Detect (INACTIVE)";
617  case 0x0100: return "Detect (QUIET)";
618  case 0x0200: return "Detect (SPD_CHD0)";
619  case 0x0300: return "Detect (SPD_CHD1)";
620  case 0x0400: return "Detect (ACTIVE0)";
621  case 0x0500: return "Detect (ACTIVE1)";
622  case 0x0600: return "Detect (P1_TO_P0)";
623  case 0x0700: return "Detect (P0_TO_P1_0)";
624  case 0x0800: return "Detect (P0_TO_P1_1)";
625  case 0x0900: return "Detect (P0_TO_P1_2)";
626  case 0xFF00: return "Detect";
627  case 0x0001: return "Polling (INACTIVE)";
628  case 0x0101: return "Polling (ACTIVE_ENTRY)";
629  case 0x0201: return "Polling (ACTIVE)";
630  case 0x0301: return "Polling (CFG)";
631  case 0x0401: return "Polling (COMP)";
632  case 0x0501: return "Polling (COMP_ENTRY)";
633  case 0x0601: return "Polling (COMP_EIOS)";
634  case 0x0701: return "Polling (COMP_EIOS_ACK)";
635  case 0x0801: return "Polling (COMP_IDLE)";
636  case 0xFF01: return "Polling";
637  case 0x0002: return "Config (INACTIVE)";
638  case 0x0102: return "Config (US_LW_START)";
639  case 0x0202: return "Config (US_LW_ACCEPT)";
640  case 0x0302: return "Config (US_LN_WAIT)";
641  case 0x0402: return "Config (US_LN_ACCEPT)";
642  case 0x0502: return "Config (DS_LW_START)";
643  case 0x0602: return "Config (DS_LW_ACCEPT)";
644  case 0x0702: return "Config (DS_LN_WAIT)";
645  case 0x0802: return "Config (DS_LN_ACCEPT)";
646  case 0x0902: return "Config (COMPLETE)";
647  case 0x0A02: return "Config (IDLE)";
648  case 0xFF02: return "Config";
649  case 0x0003: return "L0 (INACTIVE)";
650  case 0x0103: return "L0 (L0)";
651  case 0x0203: return "L0 (TX_EL_IDLE)";
652  case 0x0303: return "L0 (TX_IDLE_MIN)";
653  case 0xFF03: return "L0";
654  case 0x0004: return "Recovery (INACTIVE)";
655  case 0x0104: return "Recovery (RCVR_LOCK)";
656  case 0x0204: return "Recovery (RCVR_CFG)";
657  case 0x0304: return "Recovery (IDLE)";
658  case 0x0404: return "Recovery (SPEED0)";
659  case 0x0504: return "Recovery (SPEED1)";
660  case 0x0604: return "Recovery (SPEED2)";
661  case 0x0704: return "Recovery (SPEED3)";
662  case 0x0804: return "Recovery (EQ_PH0)";
663  case 0x0904: return "Recovery (EQ_PH1)";
664  case 0x0A04: return "Recovery (EQ_PH2)";
665  case 0x0B04: return "Recovery (EQ_PH3)";
666  case 0xFF04: return "Recovery";
667  case 0x0005: return "Disable (INACTIVE)";
668  case 0x0105: return "Disable (DISABLE0)";
669  case 0x0205: return "Disable (DISABLE1)";
670  case 0x0305: return "Disable (DISABLE2)";
671  case 0x0405: return "Disable (DISABLE3)";
672  case 0xFF05: return "Disable";
673  case 0x0006: return "Loop Back (INACTIVE)";
674  case 0x0106: return "Loop Back (ENTRY)";
675  case 0x0206: return "Loop Back (ENTRY_EXIT)";
676  case 0x0306: return "Loop Back (EIOS)";
677  case 0x0406: return "Loop Back (EIOS_ACK)";
678  case 0x0506: return "Loop Back (IDLE)";
679  case 0x0606: return "Loop Back (ACTIVE)";
680  case 0x0706: return "Loop Back (EXIT0)";
681  case 0x0806: return "Loop Back (EXIT1)";
682  case 0xFF06: return "Loop Back";
683  case 0x0007: return "Hot Reset (INACTIVE)";
684  case 0x0107: return "Hot Reset (HOT_RESET)";
685  case 0x0207: return "Hot Reset (MASTER_UP)";
686  case 0x0307: return "Hot Reset (MASTER_DOWN)";
687  case 0xFF07: return "Hot Reset";
688  case 0x0008: return "TxL0s (INACTIVE)";
689  case 0x0108: return "TxL0s (IDLE)";
690  case 0x0208: return "TxL0s (T0_L0)";
691  case 0x0308: return "TxL0s (FTS0)";
692  case 0x0408: return "TxL0s (FTS1)";
693  case 0xFF08: return "TxL0s";
694  case 0x0009: return "L1 (INACTIVE)";
695  case 0x0109: return "L1 (IDLE)";
696  case 0x0209: return "L1 (SUBSTATE)";
697  case 0x0309: return "L1 (SPD_CHG1)";
698  case 0x0409: return "L1 (T0_L0)";
699  case 0xFF09: return "L1";
700  case 0x000A: return "L2 (INACTIVE)";
701  case 0x010A: return "L2 (IDLE)";
702  case 0x020A: return "L2 (TX_WAKE0)";
703  case 0x030A: return "L2 (TX_WAKE1)";
704  case 0x040A: return "L2 (EXIT)";
705  case 0x050A: return "L2 (SPEED)";
706  case 0xFF0A: return "L2";
707  default: return "UNKNOWN";
708  }
709 
710 }
711 
712 /*********** EVENT Handling ***********/
713 
719  SWITCHTEC_EVT_FLAG_CLEAR = 1 << 0,
720  SWITCHTEC_EVT_FLAG_EN_POLL = 1 << 1,
721  SWITCHTEC_EVT_FLAG_EN_LOG = 1 << 2,
722  SWITCHTEC_EVT_FLAG_EN_CLI = 1 << 3,
723  SWITCHTEC_EVT_FLAG_EN_FATAL = 1 << 4,
724  SWITCHTEC_EVT_FLAG_DIS_POLL = 1 << 5,
725  SWITCHTEC_EVT_FLAG_DIS_LOG = 1 << 6,
726  SWITCHTEC_EVT_FLAG_DIS_CLI = 1 << 7,
727  SWITCHTEC_EVT_FLAG_DIS_FATAL = 1 << 8,
728 };
729 
738  SWITCHTEC_EVT_IDX_LOCAL = -1,
739  SWITCHTEC_EVT_IDX_ALL = -2,
740 };
741 
747  SWITCHTEC_EVT_GLOBAL,
748  SWITCHTEC_EVT_PART,
749  SWITCHTEC_EVT_PFF,
750 };
751 
753  enum switchtec_event_id e,
754  int index);
756  enum switchtec_event_id e,
757  int index);
759  enum switchtec_event_id *e,
760  int *idx);
762  const char **name,
763  const char **desc);
764 int switchtec_event_wait_for(struct switchtec_dev *dev,
765  enum switchtec_event_id e, int index,
766  struct switchtec_event_summary *res,
767  int timeout_ms);
768 
769 /******** FIRMWARE Management ********/
770 
776  SWITCHTEC_DLSTAT_READY = 0x0,
777  SWITCHTEC_DLSTAT_INPROGRESS = 0x1,
778  SWITCHTEC_DLSTAT_HEADER_INCORRECT = 0x2,
779  SWITCHTEC_DLSTAT_OFFSET_INCORRECT = 0x3,
780  SWITCHTEC_DLSTAT_CRC_INCORRECT = 0x4,
781  SWITCHTEC_DLSTAT_LENGTH_INCORRECT = 0x5,
782  SWITCHTEC_DLSTAT_HARDWARE_ERR = 0x6,
783  SWITCHTEC_DLSTAT_COMPLETES = 0x7,
784  SWITCHTEC_DLSTAT_SUCCESS_FIRM_ACT = 0x8,
785  SWITCHTEC_DLSTAT_SUCCESS_DATA_ACT = 0x9,
786  SWITCHTEC_DLSTAT_PACKAGE_TOO_SMALL = 0xa,
787  SWITCHTEC_DLSTAT_SIG_MEM_ALLOC = 0xb,
788  SWITCHTEC_DLSTAT_SEEPROM = 0xc,
789  SWITCHTEC_DLSTAT_READONLY_PARTITION = 0xd,
790  SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT = 0xe,
791  SWITCHTEC_DLSTAT_SEEPROM_TWI_NOT_ENABLED = 0xf,
792  SWITCHTEC_DLSTAT_PROGRAM_RUNNING = 0x10,
793  SWITCHTEC_DLSTAT_NOT_ALLOWED = 0x11,
794  SWITCHTEC_DLSTAT_XML_MISMATCH_ACT = 0x12,
795  SWITCHTEC_DLSTAT_UNKNOWN_ACT = 0x13,
796 
797  SWITCHTEC_DLSTAT_ERROR_PROGRAM = 0x1000,
798  SWITCHTEC_DLSTAT_ERROR_OFFSET = 0x1001,
799 
800  SWITCHTEC_DLSTAT_NO_FILE = 0x7d009,
801 };
802 
807  SWITCHTEC_FW_RW = 0,
808  SWITCHTEC_FW_RO = 1,
809 };
810 
811 enum switchtec_fw_redundancy {
812  SWITCHTEC_FW_REDUNDANCY_SET = 1,
813  SWITCHTEC_FW_REDUNDANCY_CLEAR = 0,
814 };
815 
816 int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
817  int toggle_bl2, int toggle_key,
818  int toggle_fw, int toggle_cfg);
819 int switchtec_fw_setup_redundancy(struct switchtec_dev *dev,
820  enum switchtec_fw_redundancy redund,
821  enum switchtec_fw_type type);
822 int switchtec_fw_write_fd(struct switchtec_dev *dev, int img_fd,
823  int dont_activate, int force,
824  void (*progress_callback)(int cur, int tot));
825 int switchtec_fw_write_file(struct switchtec_dev *dev, FILE *fimg,
826  int dont_activate, int force,
827  void (*progress_callback)(int cur, int tot));
828 int switchtec_fw_read_fd(struct switchtec_dev *dev, int fd,
829  unsigned long addr, size_t len,
830  void (*progress_callback)(int cur, int tot));
831 int switchtec_fw_body_read_fd(struct switchtec_dev *dev, int fd,
832  struct switchtec_fw_image_info *info,
833  void (*progress_callback)(int cur, int tot));
834 int switchtec_fw_read(struct switchtec_dev *dev, unsigned long addr,
835  size_t len, void *buf);
836 void switchtec_fw_perror(const char *s, int ret);
837 int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info);
838 int switchtec_fw_file_secure_version_newer(struct switchtec_dev *dev,
839  int img_fd);
840 const char *switchtec_fw_image_type(const struct switchtec_fw_image_info *info);
842 switchtec_fw_part_summary(struct switchtec_dev *dev);
844 int switchtec_fw_img_write_hdr(int fd, struct switchtec_fw_image_info *info);
845 int switchtec_fw_is_boot_ro(struct switchtec_dev *dev);
846 int switchtec_fw_set_boot_ro(struct switchtec_dev *dev,
847  enum switchtec_fw_ro ro);
848 enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version);
849 int switchtec_bind_info(struct switchtec_dev *dev,
850  struct switchtec_bind_status_out *bind_status,
851  int phy_port);
852 int switchtec_bind(struct switchtec_dev *dev, int par_id,
853  int log_port, int phy_port);
854 int switchtec_unbind(struct switchtec_dev *dev, int par_id, int log_port);
855 bool switchtec_stack_bif_port_valid(struct switchtec_dev *dev, int stack_id,
856  int port_id);
857 int switchtec_stack_bif_width(struct switchtec_dev *dev, int stack_id,
858  int port_bif);
859 int switchtec_get_stack_bif(struct switchtec_dev *dev, int stack_id,
860  int port_bif[SWITCHTEC_PORTS_PER_STACK]);
861 int switchtec_set_stack_bif(struct switchtec_dev *dev, int stack_id,
862  int port_bif[SWITCHTEC_PORTS_PER_STACK]);
863 
864 /********** EVENT COUNTER *********/
865 
870  UNSUP_REQ_ERR = 1 << 0,
871  ECRC_ERR = 1 << 1,
872  MALFORM_TLP_ERR = 1 << 2,
873  RCVR_OFLOW_ERR = 1 << 3,
874  CMPLTR_ABORT_ERR = 1 << 4,
875  POISONED_TLP_ERR = 1 << 5,
876  SURPRISE_DOWN_ERR = 1 << 6,
878  HDR_LOG_OFLOW_ERR = 1 << 8,
879  UNCOR_INT_ERR = 1 << 9,
880  REPLAY_TMR_TIMEOUT = 1 << 10,
882  BAD_DLLP = 1 << 12,
883  BAD_TLP = 1 << 13,
884  RCVR_ERR = 1 << 14,
885  RCV_FATAL_MSG = 1 << 15,
886  RCV_NON_FATAL_MSG = 1 << 16,
887  RCV_CORR_MSG = 1 << 17,
888  NAK_RCVD = 1 << 18,
889  RULE_TABLE_HIT = 1 << 19,
890  POSTED_TLP = 1 << 20,
891  COMP_TLP = 1 << 21,
892  NON_POSTED_TLP = 1 << 22,
893 
908 
912  ALL = (1 << 23) - 1,
913 };
914 
919 extern const struct switchtec_evcntr_type_list {
920  enum switchtec_evcntr_type_mask mask;
921  const char *name;
922  const char *help;
924 
929  unsigned port_mask; //<! Mask of ports this counter counts
930 
933  int egress; //<! If 1, count egress, otherwise on ingress
934 
939  unsigned threshold;
940 };
941 
943 const char *switchtec_evcntr_type_str(int *type_mask);
944 int switchtec_evcntr_setup(struct switchtec_dev *dev, unsigned stack_id,
945  unsigned cntr_id,
946  struct switchtec_evcntr_setup *setup);
947 int switchtec_evcntr_get_setup(struct switchtec_dev *dev, unsigned stack_id,
948  unsigned cntr_id, unsigned nr_cntrs,
949  struct switchtec_evcntr_setup *res);
950 int switchtec_evcntr_get(struct switchtec_dev *dev, unsigned stack_id,
951  unsigned cntr_id, unsigned nr_cntrs, unsigned *res,
952  int clear);
953 int switchtec_evcntr_get_both(struct switchtec_dev *dev, unsigned stack_id,
954  unsigned cntr_id, unsigned nr_cntrs,
955  struct switchtec_evcntr_setup *setup,
956  unsigned *counts, int clear);
957 int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms);
958 
959 /********** BANDWIDTH COUNTER *********/
960 
965  uint64_t time_us;
967  uint64_t posted;
968  uint64_t comp;
969  uint64_t nonposted;
970  } egress,
971  ingress;
972 };
973 
974 void switchtec_bwcntr_sub(struct switchtec_bwcntr_res *new_cntr,
975  struct switchtec_bwcntr_res *old_cntr);
976 int switchtec_bwcntr_set_many(struct switchtec_dev *dev, int nr_ports,
977  int * phys_port_ids,
978  enum switchtec_bw_type bw_type);
979 int switchtec_bwcntr_set_all(struct switchtec_dev *dev,
980  enum switchtec_bw_type bw_type);
981 int switchtec_bwcntr_many(struct switchtec_dev *dev, int nr_ports,
982  int *phys_port_ids, int clear,
983  struct switchtec_bwcntr_res *res);
984 int switchtec_bwcntr_all(struct switchtec_dev *dev, int clear,
985  struct switchtec_port_id **ports,
986  struct switchtec_bwcntr_res **res);
987 uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d);
988 
989 /********** LATENCY COUNTER *********/
990 
991 #define SWITCHTEC_LAT_ALL_INGRESS 63
992 
993 int switchtec_lat_setup_many(struct switchtec_dev *dev, int nr_ports,
994  int *egress_port_ids, int *ingress_port_ids);
995 int switchtec_lat_setup(struct switchtec_dev *dev, int egress_port_id,
996  int ingress_port_id, int clear);
997 int switchtec_lat_get_many(struct switchtec_dev *dev, int nr_ports,
998  int clear, int *egress_port_ids,
999  int *cur_ns, int *max_ns);
1000 int switchtec_lat_get(struct switchtec_dev *dev, int clear,
1001  int egress_port_ids, int *cur_ns,
1002  int *max_ns);
1003 
1004 /********** GLOBAL ADDRESS SPACE ACCESS *********/
1005 
1006 /*
1007  * GAS map maps the hardware registers into user memory space.
1008  * Needless to say, this can be very dangerous and should only
1009  * be done if you know what you are doing. Any register accesses
1010  * that use this will remain unsupported by Microsemi unless it's
1011  * done within the switchtec user project or otherwise specified.
1012  */
1013 
1014 gasptr_t switchtec_gas_map(struct switchtec_dev *dev, int writeable,
1015  size_t *map_size);
1016 void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map);
1017 
1018 /********** DIAGNOSTIC FUNCTIONS *********/
1019 
1020 #define SWITCHTEC_DIAG_CROSS_HAIR_ALL_LANES -1
1021 #define SWITCHTEC_DIAG_CROSS_HAIR_MAX_LANES 64
1022 
1023 enum switchtec_diag_cross_hair_state {
1024  SWITCHTEC_DIAG_CROSS_HAIR_DISABLED = 0,
1025  SWITCHTEC_DIAG_CROSS_HAIR_RESVD,
1026  SWITCHTEC_DIAG_CROSS_HAIR_WAITING,
1027  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_RIGHT,
1028  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_RIGHT,
1029  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_RIGHT,
1030  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_LEFT,
1031  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_LEFT,
1032  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_LEFT,
1033  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_TOP_RIGHT,
1034  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_TOP_RIGHT,
1035  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_TOP_RIGHT,
1036  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_BOT_RIGHT,
1037  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_BOT_RIGHT,
1038  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_BOT_RIGHT,
1039  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_TOP_LEFT,
1040  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_TOP_LEFT,
1041  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_TOP_LEFT,
1042  SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_BOT_LEFT,
1043  SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_BOT_LEFT,
1044  SWITCHTEC_DIAG_CROSS_HAIR_FINAL_BOT_LEFT,
1045  SWITCHTEC_DIAG_CROSS_HAIR_DONE,
1046  SWITCHTEC_DIAG_CROSS_HAIR_ERROR,
1047 };
1048 
1050  enum switchtec_diag_cross_hair_state state;
1051  int lane_id;
1052 
1053  union {
1054  struct {
1055  /* Valid when state is Error */
1056  int prev_state;
1057  int x_pos;
1058  int y_pos;
1059  };
1060  /* Valid when state is DONE */
1061  struct {
1062  int eye_left_lim;
1063  int eye_right_lim;
1064  int eye_bot_left_lim;
1065  int eye_bot_right_lim;
1066  int eye_top_left_lim;
1067  int eye_top_right_lim;
1068  };
1069  };
1070 };
1071 
1073  int port_id;
1074  int lane_id;
1075  int ctle;
1076  int target_amplitude;
1077  int speculative_dfe;
1078  int dynamic_dfe[7];
1079 };
1080 
1082  int lane_cnt;
1083  struct {
1084  int pre;
1085  int post;
1086  } cursors[16];
1087 };
1088 
1090  int lane_id;
1091  int step_cnt;
1092 
1093  struct {
1094  int pre_cursor;
1095  int post_cursor;
1096  int fom;
1097  int pre_cursor_up;
1098  int post_cursor_up;
1099  int error_status;
1100  int active_status;
1101  int speed;
1102  } steps[126];
1103 };
1104 
1106  int fs;
1107  int lf;
1108 };
1109 
1111  int ctle2_rx_mode;
1112  int dtclk_5;
1113  int dtclk_8_6;
1114  int dtclk_9;
1115 };
1116 
1118  const char *tag;
1119  const char *desc;
1120  bool reserved;
1121 };
1122 
1123 enum switchtec_diag_eye_data_mode {
1124  SWITCHTEC_DIAG_EYE_RAW,
1125  SWITCHTEC_DIAG_EYE_RATIO,
1126 };
1127 
1128 enum switchtec_diag_loopback_enable {
1129  SWITCHTEC_DIAG_LOOPBACK_RX_TO_TX = 1 << 0,
1130  SWITCHTEC_DIAG_LOOPBACK_TX_TO_RX = 1 << 1,
1131  SWITCHTEC_DIAG_LOOPBACK_LTSSM = 1 << 2,
1132 };
1133 
1134 enum switchtec_diag_pattern {
1135  SWITCHTEC_DIAG_PATTERN_PRBS_7,
1136  SWITCHTEC_DIAG_PATTERN_PRBS_11,
1137  SWITCHTEC_DIAG_PATTERN_PRBS_23,
1138  SWITCHTEC_DIAG_PATTERN_PRBS_31,
1139  SWITCHTEC_DIAG_PATTERN_PRBS_9,
1140  SWITCHTEC_DIAG_PATTERN_PRBS_15,
1141  SWITCHTEC_DIAG_PATTERN_PRBS_DISABLED,
1142 };
1143 
1144 enum switchtec_diag_ltssm_speed {
1145  SWITCHTEC_DIAG_LTSSM_GEN1 = 0,
1146  SWITCHTEC_DIAG_LTSSM_GEN2 = 1,
1147  SWITCHTEC_DIAG_LTSSM_GEN3 = 2,
1148  SWITCHTEC_DIAG_LTSSM_GEN4 = 3,
1149 };
1150 
1151 enum switchtec_diag_end {
1152  SWITCHTEC_DIAG_LOCAL,
1153  SWITCHTEC_DIAG_FAR_END,
1154 };
1155 
1156 enum switchtec_diag_link {
1157  SWITCHTEC_DIAG_LINK_CURRENT,
1158  SWITCHTEC_DIAG_LINK_PREVIOUS,
1159 };
1160 
1162  unsigned int timestamp;
1163  float link_rate;
1164  int link_state;
1165 };
1166 
1167 int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id);
1168 int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev);
1169 int switchtec_diag_cross_hair_get(struct switchtec_dev *dev, int start_lane_id,
1170  int num_lanes, struct switchtec_diag_cross_hair *res);
1171 
1172 int switchtec_diag_eye_set_mode(struct switchtec_dev *dev,
1173  enum switchtec_diag_eye_data_mode mode);
1174 int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4],
1175  struct range *x_range, struct range *y_range,
1176  int step_interval);
1177 int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels,
1178  size_t pixel_cnt, int *lane_id);
1179 int switchtec_diag_eye_cancel(struct switchtec_dev *dev);
1180 
1181 int switchtec_diag_loopback_set(struct switchtec_dev *dev, int port_id,
1182  int enable, enum switchtec_diag_ltssm_speed ltssm_speed);
1183 int switchtec_diag_loopback_get(struct switchtec_dev *dev, int port_id,
1184  int *enabled, enum switchtec_diag_ltssm_speed *ltssm_speed);
1185 int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
1186  enum switchtec_diag_pattern type);
1187 int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
1188  enum switchtec_diag_pattern *type);
1189 int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,
1190  enum switchtec_diag_pattern type);
1191 int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id,
1192  int lane_id, enum switchtec_diag_pattern *type,
1193  unsigned long long *err_cnt);
1194 int switchtec_diag_pattern_inject(struct switchtec_dev *dev, int port_id,
1195  unsigned int err_cnt);
1196 
1197 int switchtec_diag_rcvr_obj(struct switchtec_dev *dev, int port_id,
1198  int lane_id, enum switchtec_diag_link link,
1199  struct switchtec_rcvr_obj *res);
1200 int switchtec_diag_rcvr_ext(struct switchtec_dev *dev, int port_id,
1201  int lane_id, enum switchtec_diag_link link,
1202  struct switchtec_rcvr_ext *res);
1203 
1204 int switchtec_diag_port_eq_tx_coeff(struct switchtec_dev *dev, int port_id,
1205  enum switchtec_diag_end end, enum switchtec_diag_link link,
1206  struct switchtec_port_eq_coeff *res);
1207 int switchtec_diag_port_eq_tx_table(struct switchtec_dev *dev, int port_id,
1208  enum switchtec_diag_link link,
1209  struct switchtec_port_eq_table *res);
1210 int switchtec_diag_port_eq_tx_fslf(struct switchtec_dev *dev, int port_id,
1211  int lane_id, enum switchtec_diag_end end,
1212  enum switchtec_diag_link link,
1213  struct switchtec_port_eq_tx_fslf *res);
1214 
1215 int switchtec_diag_perm_table(struct switchtec_dev *dev,
1216  struct switchtec_mrpc table[MRPC_MAX_ID]);
1217 int switchtec_diag_refclk_ctl(struct switchtec_dev *dev, int stack_id, bool en);
1218 int switchtec_diag_ltssm_log(struct switchtec_dev *dev,
1219  int port, int *log_count,
1220  struct switchtec_diag_ltssm_log *log_data);
1221 
1222 #ifdef __cplusplus
1223 }
1224 #endif
1225 
1226 #endif
char version[32]
Firmware/Config version.
Definition: switchtec.h:255
unsigned char cfg_lnk_width
Configured link width.
Definition: switchtec.h:162
unsigned char neg_lnk_width
Negotiated link width.
Definition: switchtec.h:163
Completion TLP.
Definition: switchtec.h:891
char product_rev[8]
Product revision.
Definition: switchtec.h:136
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
char * pci_dev
PCI BDF of the device on the port.
Definition: switchtec.h:176
unsigned int acs_ctrl
ACS Setting of the Port.
Definition: switchtec.h:180
ECRC Error.
Definition: switchtec.h:871
static int switchtec_is_pfxl(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-L.
Definition: switchtec.h:455
switchtec_evcntr_type_mask
Event counter type mask (may be or-d together)
Definition: switchtec.h:869
Bad TLP.
Definition: switchtec.h:883
void switchtec_status_free(struct switchtec_status *status, int ports)
Free a list of status structures allocated by switchtec_status()
Definition: switchtec.c:574
Unsupported Request Error.
Definition: switchtec.h:870
unsigned char upstream
1 if this is an upstream port
Definition: switchtec.h:148
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:425
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
unsigned char link_rate
Link rate/gen.
Definition: switchtec.h:165
Replay Timer Timeout.
Definition: switchtec.h:880
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_log_parse_type
Log types to parse.
Definition: switchtec.h:209
Rule Search Table Rule Hit.
Definition: switchtec.h:889
enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version)
Extract generation information from FW version number.
Definition: fw.c:397
_PURE int switchtec_device_id(struct switchtec_dev *dev)
Get the device id of the device.
Definition: switchtec.c:338
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_log_def_type
Log definition data types.
Definition: switchtec.h:231
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
size_t part_addr
Address of the partition.
Definition: switchtec.h:256
uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d)
Get the total.
Definition: pmon.c:513
uint64_t comp
Completion TLP bytes.
Definition: switchtec.h:968
Uncorrectable Internal Error.
Definition: switchtec.h:879
uint64_t time_us
Time (in microseconds)
Definition: switchtec.h:965
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
Port identification.
Definition: switchtec.h:144
struct switchtec_port_id port
Port ID.
Definition: switchtec.h:161
static const float switchtec_gen_transfers[]
Number of GT/s capable for each PCI generation or link_rate.
Definition: switchtec.h:606
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
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_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
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_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
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
Receive Correctable Error Message.
Definition: switchtec.h:887
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_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
static const char * switchtec_gen_str(struct switchtec_dev *dev)
Return the generation string of a Switchtec device.
Definition: switchtec.h:547
unsigned char partition
Partition the port is in.
Definition: switchtec.h:145
enum switchtec_evcntr_type_mask type_mask
Event counter types to count.
Definition: switchtec.h:932
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:486
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
unsigned long image_crc
CRC checksum of the image.
Definition: switchtec.h:260
static int switchtec_is_pfxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-A.
Definition: switchtec.h:471
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
enum switchtec_fw_type type
Image partition type.
Definition: switchtec.h:254
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
struct switchtec_dev * switchtec_open_eth(const char *ip, const int inst)
Open a switchtec device over ethernet.
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_gen
The PCIe generations.
Definition: switchtec.h:86
unsigned char stk_id
Port number within the stack.
Definition: switchtec.h:149
switchtec_event_id
Enumeration of all possible events.
Definition: switchtec.h:304
Bad DLLP.
Definition: switchtec.h:882
unsigned char first_act_lane
First active lane.
Definition: switchtec.h:170
Information about a firmware image or partition.
Definition: switchtec.h:251
struct switchtec_bwcntr_res::switchtec_bwcntr_dir egress
Bandwidth out of the port.
switchtec_boot_phase
Device boot phase.
Definition: switchtec.h:106
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
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
Mask indicating all possible errors.
Definition: switchtec.h:897
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
char * pci_bdf_path
PCI BDF path of the port.
Definition: switchtec.h:174
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
Malformed TLP Error.
Definition: switchtec.h:872
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:1542
static int switchtec_is_gen5(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 5 device.
Definition: switchtec.h:439
Completer Abort Error.
Definition: switchtec.h:874
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
unsigned long part_id
Image partition ID.
Definition: switchtec.h:253
void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map)
Unmap the GAS region mapped with.
Definition: platform.c:267
Posted TLP.
Definition: switchtec.h:890
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
Structure used to setup an event counter.
Definition: switchtec.h:928
switchtec_bw_type
The types of bandwidth.
Definition: switchtec.h:186
int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev)
Disable active cross hair.
Definition: diag.c:69
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:1994
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
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
Non-Posted TLP.
Definition: switchtec.h:892
__gas struct switchtec_gas * gasptr_t
Shortform for a pointer to the GAS register space.
Definition: switchtec.h:80
static int switchtec_is_pax_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX(A).
Definition: switchtec.h:539
char product_id[32]
Product ID.
Definition: switchtec.h:135
int switchtec_list(struct switchtec_device_info **devlist)
List all the switchtec devices in the system.
unsigned char phys_id
Physical port number.
Definition: switchtec.h:150
Replay Number Rollover.
Definition: switchtec.h:881
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:1930
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
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
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
Event summary bitmaps.
Definition: switchtec.h:289
static int switchtec_is_psx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX(A).
Definition: switchtec.h:506
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
int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms)
Block until any event counter has reached its threshold.
Definition: pmon.c:325
static int switchtec_is_pax(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX.
Definition: switchtec.h:523
size_t image_len
Length of the image.
Definition: switchtec.h:259
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:305
uint64_t part_bitmap
Bitmap of partitions with active events.
Definition: switchtec.h:291
int switchtec_evcntr_type_count(void)
Get the number of event counter types.
Definition: pmon.c:95
switchtec_log_type
Describe the type of logs too dump.
Definition: switchtec.h:195
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:1454
static int switchtec_is_pfx(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX.
Definition: switchtec.h:447
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&#39;s flash data into a file.
Definition: fw.c:1434
float switchtec_die_temp(struct switchtec_dev *dev)
Get the die temperature of the switchtec device.
Definition: switchtec.c:1780
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:2057
int switchtec_diag_eye_cancel(struct switchtec_dev *dev)
Cancel in-progress eye capture.
Definition: diag.c:306
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:2126
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
void switchtec_fw_perror(const char *s, int ret)
Print an error string to stdout.
Definition: fw.c:521
char path[PATH_MAX]
Path to the device.
Definition: switchtec.h:138
unsigned threshold
Threshold to count to before generating an interrupt.
Definition: switchtec.h:939
char desc[256]
Device description, if available.
Definition: switchtec.h:133
uint64_t nonposted
Non-Posted TLP bytes.
Definition: switchtec.h:969
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:576
static int switchtec_is_gen4(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 4 device.
Definition: switchtec.h:431
int switchtec_diag_perm_table(struct switchtec_dev *dev, struct switchtec_mrpc table[MRPC_MAX_ID])
Get the permission table.
Definition: diag.c:862
_PURE int switchtec_partition(struct switchtec_dev *dev)
Get the partiton number of the device that was opened.
Definition: switchtec.c:396
NAK Received.
Definition: switchtec.h:888
unsigned char stack
Stack number.
Definition: switchtec.h:147
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
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&#39;s flash image body into a file.
Definition: fw.c:1483
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
const char * lane_reversal_str
Lane reversal as a string.
Definition: switchtec.h:169
static int switchtec_is_psxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX-A.
Definition: switchtec.h:498
int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id)
Enable cross hair on specified lane.
Definition: diag.c:52
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
static int switchtec_is_paxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX-A.
Definition: switchtec.h:531
Definition: utils.h:34
int device_id
Device ID.
Definition: switchtec.h:178
const char * switchtec_strerror(void)
Return a message coresponding to the last error.
Definition: switchtec.c:613
int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output)
Perform an MRPC echo command.
Definition: switchtec.c:767
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:773
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:1647
enum switchtec_gen gen
Image generation.
Definition: switchtec.h:252
switchtec_fw_ro
Flag which indicates if a partition is read-only or not.
Definition: switchtec.h:806
static int switchtec_is_pfxi(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-I.
Definition: switchtec.h:463
Port status structure.
Definition: switchtec.h:160
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
void switchtec_fw_part_summary_free(struct switchtec_fw_part_summary *summary)
Free a firmware part summary data structure.
Definition: fw.c:1372
Mask indicating all event types.
Definition: switchtec.h:912
static const char * switchtec_rev_str(enum switchtec_rev rev)
Return the revision string.
Definition: switchtec.h:561
unsigned char lane_reversal
Lane reversal.
Definition: switchtec.h:168
size_t part_body_offset
Partition image body offset.
Definition: switchtec.h:258
int switchtec_fw_is_boot_ro(struct switchtec_dev *dev)
Check if the boot partition is marked as read-only.
Definition: fw.c:1567
int switchtec_fw_read(struct switchtec_dev *dev, unsigned long addr, size_t len, void *buf)
Read a Switchtec device&#39;s flash data.
Definition: fw.c:1390
char * class_devices
Comma seperated list of classes.
Definition: switchtec.h:179
switchtec_variant
The variant types of Switchtec device.
Definition: switchtec.h:116
const char * ltssm_str
Link state as a string.
Definition: switchtec.h:167
uint64_t global
Bitmap of global events.
Definition: switchtec.h:290
int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info)
Retrieve information about a firmware image file.
Definition: fw.c:740
Header Log Overflow Error.
Definition: switchtec.h:878
unsigned pff[SWITCHTEC_MAX_PFF_CSR]
Bitmap of events in each port function.
Definition: switchtec.h:298
unsigned part[SWITCHTEC_MAX_PARTS]
Bitmap of events in each partition.
Definition: switchtec.h:295
Mask indicating all TLP types.
Definition: switchtec.h:907
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:2082
Surprise Down Error.
Definition: switchtec.h:876
int switchtec_fw_setup_redundancy(struct switchtec_dev *dev, enum switchtec_fw_redundancy redund, enum switchtec_fw_type type)
Set or clear the redundancy flag of a partition type.
Definition: fw.c:255
void switchtec_list_free(struct switchtec_device_info *devlist)
Free a list of device info structures allocated by switchtec_list()
Definition: switchtec.c:231
switchtec_fw_dlstatus
Firmware update status.
Definition: switchtec.h:775
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:825
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
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
char pci_dev[256]
PCI BDF string.
Definition: switchtec.h:134
static int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX or PSX.
Definition: switchtec.h:515
struct switchtec_dev * switchtec_open_uart(int fd)
Open a switchtec device behind a uart device.
int switchtec_bwcntr_all(struct switchtec_dev *dev, int clear, struct switchtec_port_id **ports, struct switchtec_bwcntr_res **res)
Retrieve the bandwidth counter results for all the ports in the system.
Definition: pmon.c:473
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:1287
static int switchtec_is_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX(L/I/A).
Definition: switchtec.h:479
struct switchtec_dev * switchtec_open_by_path(const char *path)
Open a switchtec device by path.
char fw_version[32]
Firmware version.
Definition: switchtec.h:137
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:1890
size_t part_len
Length of the partition.
Definition: switchtec.h:257
switchtec_event_special
Special event indexes numbers.
Definition: switchtec.h:737
static int switchtec_is_gen3(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 3 device.
Definition: switchtec.h:423
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
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
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:1725
int vendor_id
Vendor ID.
Definition: switchtec.h:177
char name[256]
Device name, eg. switchtec0.
Definition: switchtec.h:132
switchtec_event_flags
Event control flags.
Definition: switchtec.h:718
switchtec_event_type
There are three event types indicated by this enumeration: global, partition and port function...
Definition: switchtec.h:746
void switchtec_perror(const char *str)
Print an error string to stdout.
Definition: switchtec.c:736
int switchtec_fw_set_boot_ro(struct switchtec_dev *dev, enum switchtec_fw_ro ro)
Set or clear a boot partition&#39;s read-only flag.
Definition: fw.c:1606
Poisoned TLP Error.
Definition: switchtec.h:875
Receive FATAL Error Message.
Definition: switchtec.h:885
switchtec_rev
Device hardware revision.
Definition: switchtec.h:96
struct switchtec_bwcntr_res::switchtec_bwcntr_dir ingress
Bandwidth into the port.
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
struct switchtec_dev * switchtec_open(const char *device)
Open a Switchtec device by string.
Definition: switchtec.c:253
Information about log file and log definition file.
Definition: switchtec.h:217
Null-terminated list of all event counter types with a name and help text.
Definition: switchtec.h:919
char * pci_bdf
PCI BDF of the port.
Definition: switchtec.h:173
_PURE const char * switchtec_name(struct switchtec_dev *dev)
Get the string that was used to open the deviec.
Definition: switchtec.c:386
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
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_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
Receiver Error.
Definition: switchtec.h:884
Receiver Overflow Error.
Definition: switchtec.h:873
unsigned char log_id
Logical port number.
Definition: switchtec.h:151
Represents a Switchtec device in the switchtec_list() function.
Definition: switchtec.h:131
struct switchtec_dev * switchtec_open_i2c(const char *path, int i2c_addr)
Open a switchtec device behind an I2C device.
Data Link Protocol Error.
Definition: switchtec.h:877
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:1535
struct switchtec_dev * switchtec_open_by_index(int index)
Open a switchtec device by index.
int switchtec_event_ctl(struct switchtec_dev *dev, enum switchtec_event_id e, int index, int flags, uint32_t data[5])
Enable, disable and clear events or retrieve event data.
Definition: platform.c:313
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
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
struct switchtec_dev * switchtec_open_by_pci_addr(int domain, int bus, int device, int func)
Open a switchtec device by PCI address (BDF)
int switchtec_lat_setup(struct switchtec_dev *dev, int egress_port_id, int ingress_port_id, int clear)
Setup a latency counter.
Definition: pmon.c:557
Bandwidth counter result struct.
Definition: switchtec.h:964
unsigned local_part
Bitmap of events in the local partition.
Definition: switchtec.h:292
uint64_t posted
Posted TLP bytes.
Definition: switchtec.h:967
static const char * switchtec_variant_str(struct switchtec_dev *dev)
Return the variant string of a Switchtec device.
Definition: switchtec.h:589
unsigned char link_up
1 if the link is up
Definition: switchtec.h:164
int switchtec_hard_reset(struct switchtec_dev *dev)
Perform an MRPC hard reset command.
Definition: switchtec.c:783
Receive Non-FATAL Error Message.
Definition: switchtec.h:886
static int switchtec_is_psx(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX.
Definition: switchtec.h:490
void switchtec_close(struct switchtec_dev *dev)
Close a Switchtec device handle.
Definition: platform.c:101
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:2041
static const float switchtec_gen_datarate[]
Number of GB/s capable for each PCI generation or link_rate.
Definition: switchtec.h:608
uint16_t ltssm
Link state.
Definition: switchtec.h:166