Switchtec Userspace PROJECT_NUMBER = 3.1
Loading...
Searching...
No Matches
switchtec.h
Go to the documentation of this file.
1/*
2 * Microsemi Switchtec(tm) PCIe Management Library
3 * Copyright (c) 2017, Microsemi Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25#ifndef LIBSWITCHTEC_SWITCHTEC_H
26#define LIBSWITCHTEC_SWITCHTEC_H
27
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
45extern "C" {
46#endif
47
48struct 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
80typedef __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;
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;
175
176 char *pci_dev;
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
236enum 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
342struct switchtec_dev *switchtec_open(const char *device);
343struct switchtec_dev *switchtec_open_by_path(const char *path);
344struct switchtec_dev *switchtec_open_by_index(int index);
345struct switchtec_dev *switchtec_open_by_pci_addr(int domain, int bus,
346 int device, int func);
347struct switchtec_dev *switchtec_open_i2c(const char *path, int i2c_addr);
348struct switchtec_dev *switchtec_open_i2c_by_adapter(int adapter, int i2c_addr);
349struct switchtec_dev *switchtec_open_uart(int fd);
350struct switchtec_dev *switchtec_open_eth(const char *ip, const int inst);
351
352void switchtec_close(struct switchtec_dev *dev);
353int switchtec_list(struct switchtec_device_info **devlist);
354void switchtec_list_free(struct switchtec_device_info *devlist);
355int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf,
356 size_t buflen);
357int switchtec_cmd(struct switchtec_dev *dev, uint32_t cmd,
358 const void *payload, size_t payload_len, void *resp,
359 size_t resp_len);
360int switchtec_get_devices(struct switchtec_dev *dev,
361 struct switchtec_status *status,
362 int ports);
363int switchtec_pff_to_port(struct switchtec_dev *dev, int pff,
364 int *partition, int *port);
365int switchtec_port_to_pff(struct switchtec_dev *dev, int partition,
366 int port, int *pff);
367int switchtec_event_summary(struct switchtec_dev *dev,
368 struct switchtec_event_summary *sum);
369int switchtec_event_check(struct switchtec_dev *dev,
370 struct switchtec_event_summary *check,
371 struct switchtec_event_summary *res);
372int switchtec_event_ctl(struct switchtec_dev *dev,
373 enum switchtec_event_id e,
374 int index, int flags,
375 uint32_t data[5]);
376int 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
386switchtec_boot_phase(struct switchtec_dev *dev);
387int switchtec_set_pax_id(struct switchtec_dev *dev, int pax_id);
388int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output);
389int switchtec_hard_reset(struct switchtec_dev *dev);
390int switchtec_status(struct switchtec_dev *dev,
391 struct switchtec_status **status);
392void switchtec_status_free(struct switchtec_status *status, int ports);
393int switchtec_get_device_info(struct switchtec_dev *dev,
394 enum switchtec_boot_phase *phase,
395 enum switchtec_gen *gen,
396 enum switchtec_rev *rev);
397const char *switchtec_strerror(void);
398void switchtec_perror(const char *str);
399int 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);
402int 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);
407int switchtec_log_def_to_file(struct switchtec_dev *dev,
408 enum switchtec_log_def_type type,
409 FILE* file);
410float switchtec_die_temp(struct switchtec_dev *dev);
411int switchtec_calc_lane_id(struct switchtec_dev *dev, int phys_port_id,
412 int lane_id, struct switchtec_status *port);
413int 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);
416int 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
423static inline int switchtec_is_gen3(struct switchtec_dev *dev)
424{
425 return switchtec_gen(dev) == SWITCHTEC_GEN3;
426}
427
431static inline int switchtec_is_gen4(struct switchtec_dev *dev)
432{
433 return switchtec_gen(dev) == SWITCHTEC_GEN4;
434}
435
439static inline int switchtec_is_gen5(struct switchtec_dev *dev)
440{
441 return switchtec_gen(dev) == SWITCHTEC_GEN5;
442}
443
447static inline int switchtec_max_supported_ports(struct switchtec_dev *dev)
448{
449 return switchtec_is_gen5(dev) ? SWITCHTEC_MAX_PORTS :
450 switchtec_is_gen4(dev) ? 52 : 48;
451}
452
456static inline int switchtec_is_pfx(struct switchtec_dev *dev)
457{
458 return switchtec_variant(dev) == SWITCHTEC_PFX;
459}
460
464static inline int switchtec_is_pfxl(struct switchtec_dev *dev)
465{
466 return switchtec_variant(dev) == SWITCHTEC_PFXL;
467}
468
472static inline int switchtec_is_pfxi(struct switchtec_dev *dev)
473{
474 return switchtec_variant(dev) == SWITCHTEC_PFXI;
475}
476
480static inline int switchtec_is_pfxa(struct switchtec_dev *dev)
481{
482 return switchtec_variant(dev) == SWITCHTEC_PFXA;
483}
484
488static inline int switchtec_is_pfx_all(struct switchtec_dev *dev)
489{
490 return switchtec_is_pfx(dev) ||
491 switchtec_is_pfxl(dev) ||
492 switchtec_is_pfxi(dev) ||
494}
495
499static inline int switchtec_is_psx(struct switchtec_dev *dev)
500{
501 return switchtec_variant(dev) == SWITCHTEC_PSX;
502}
503
507static inline int switchtec_is_psxa(struct switchtec_dev *dev)
508{
509 return switchtec_variant(dev) == SWITCHTEC_PSXA;
510}
511
515static inline int switchtec_is_psx_all(struct switchtec_dev *dev)
516{
517 return switchtec_is_psx(dev) ||
519}
520
524static inline int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
525{
526 return switchtec_is_psx_all(dev) || switchtec_is_pfx_all(dev);
527}
528
532static inline int switchtec_is_pax(struct switchtec_dev *dev)
533{
534 return switchtec_variant(dev) == SWITCHTEC_PAX;
535}
536
540static inline int switchtec_is_paxa(struct switchtec_dev *dev)
541{
542 return switchtec_variant(dev) == SWITCHTEC_PAXA;
543}
544
548static inline int switchtec_is_pax_all(struct switchtec_dev *dev)
549{
550 return switchtec_is_pax(dev) || switchtec_is_paxa(dev);
551}
552
556static inline const char *switchtec_gen_str(struct switchtec_dev *dev)
557{
558 const char *str;
559
560 str = switchtec_is_gen3(dev) ? "GEN3" :
561 switchtec_is_gen4(dev) ? "GEN4" :
562 switchtec_is_gen5(dev) ? "GEN5" : "Unknown";
563
564 return str;
565}
566
570static inline const char *switchtec_rev_str(enum switchtec_rev rev)
571{
572 const char *str;
573
574 str = (rev == SWITCHTEC_REVA) ? "REVA" :
575 (rev == SWITCHTEC_REVB) ? "REVB" :
576 (rev == SWITCHTEC_REVC) ? "REVC" : "Unknown";
577
578 return str;
579}
580
584static inline const char *
586{
587 switch (inf->gen) {
588 case SWITCHTEC_GEN3: return "GEN3";
589 case SWITCHTEC_GEN4: return "GEN4";
590 case SWITCHTEC_GEN5: return "GEN5";
591 default: return "UNKNOWN";
592 }
593}
594
598static inline const char *switchtec_variant_str(struct switchtec_dev *dev)
599{
600 const char *str;
601
602 str = switchtec_is_pfx(dev) ? "PFX" :
603 switchtec_is_pfxl(dev) ? "PFX-L" :
604 switchtec_is_pfxi(dev) ? "PFX-I" :
605 switchtec_is_psx(dev) ? "PSX" :
606 switchtec_is_pax(dev) ? "PAX" :
607 switchtec_is_pfxa(dev) ? "PFX-A" :
608 switchtec_is_psxa(dev) ? "PSX-A" :
609 switchtec_is_paxa(dev) ? "PAX-A" : "Unknown";
610
611 return str;
612}
613
615static const float switchtec_gen_transfers[] = {0, 2.5, 5, 8, 16};
617static const float switchtec_gen_datarate[] = {0, 250, 500, 985, 1969};
618
619static inline const char *switchtec_ltssm_str(int ltssm, int show_minor)
620{
621 if (!show_minor)
622 ltssm |= 0xFF00;
623
624 switch(ltssm) {
625 case 0x0000: return "Detect (INACTIVE)";
626 case 0x0100: return "Detect (QUIET)";
627 case 0x0200: return "Detect (SPD_CHD0)";
628 case 0x0300: return "Detect (SPD_CHD1)";
629 case 0x0400: return "Detect (ACTIVE0)";
630 case 0x0500: return "Detect (ACTIVE1)";
631 case 0x0600: return "Detect (P1_TO_P0)";
632 case 0x0700: return "Detect (P0_TO_P1_0)";
633 case 0x0800: return "Detect (P0_TO_P1_1)";
634 case 0x0900: return "Detect (P0_TO_P1_2)";
635 case 0xFF00: return "Detect";
636 case 0x0001: return "Polling (INACTIVE)";
637 case 0x0101: return "Polling (ACTIVE_ENTRY)";
638 case 0x0201: return "Polling (ACTIVE)";
639 case 0x0301: return "Polling (CFG)";
640 case 0x0401: return "Polling (COMP)";
641 case 0x0501: return "Polling (COMP_ENTRY)";
642 case 0x0601: return "Polling (COMP_EIOS)";
643 case 0x0701: return "Polling (COMP_EIOS_ACK)";
644 case 0x0801: return "Polling (COMP_IDLE)";
645 case 0xFF01: return "Polling";
646 case 0x0002: return "Config (INACTIVE)";
647 case 0x0102: return "Config (US_LW_START)";
648 case 0x0202: return "Config (US_LW_ACCEPT)";
649 case 0x0302: return "Config (US_LN_WAIT)";
650 case 0x0402: return "Config (US_LN_ACCEPT)";
651 case 0x0502: return "Config (DS_LW_START)";
652 case 0x0602: return "Config (DS_LW_ACCEPT)";
653 case 0x0702: return "Config (DS_LN_WAIT)";
654 case 0x0802: return "Config (DS_LN_ACCEPT)";
655 case 0x0902: return "Config (COMPLETE)";
656 case 0x0A02: return "Config (IDLE)";
657 case 0xFF02: return "Config";
658 case 0x0003: return "L0 (INACTIVE)";
659 case 0x0103: return "L0 (L0)";
660 case 0x0203: return "L0 (TX_EL_IDLE)";
661 case 0x0303: return "L0 (TX_IDLE_MIN)";
662 case 0xFF03: return "L0";
663 case 0x0004: return "Recovery (INACTIVE)";
664 case 0x0104: return "Recovery (RCVR_LOCK)";
665 case 0x0204: return "Recovery (RCVR_CFG)";
666 case 0x0304: return "Recovery (IDLE)";
667 case 0x0404: return "Recovery (SPEED0)";
668 case 0x0504: return "Recovery (SPEED1)";
669 case 0x0604: return "Recovery (SPEED2)";
670 case 0x0704: return "Recovery (SPEED3)";
671 case 0x0804: return "Recovery (EQ_PH0)";
672 case 0x0904: return "Recovery (EQ_PH1)";
673 case 0x0A04: return "Recovery (EQ_PH2)";
674 case 0x0B04: return "Recovery (EQ_PH3)";
675 case 0xFF04: return "Recovery";
676 case 0x0005: return "Disable (INACTIVE)";
677 case 0x0105: return "Disable (DISABLE0)";
678 case 0x0205: return "Disable (DISABLE1)";
679 case 0x0305: return "Disable (DISABLE2)";
680 case 0x0405: return "Disable (DISABLE3)";
681 case 0xFF05: return "Disable";
682 case 0x0006: return "Loop Back (INACTIVE)";
683 case 0x0106: return "Loop Back (ENTRY)";
684 case 0x0206: return "Loop Back (ENTRY_EXIT)";
685 case 0x0306: return "Loop Back (EIOS)";
686 case 0x0406: return "Loop Back (EIOS_ACK)";
687 case 0x0506: return "Loop Back (IDLE)";
688 case 0x0606: return "Loop Back (ACTIVE)";
689 case 0x0706: return "Loop Back (EXIT0)";
690 case 0x0806: return "Loop Back (EXIT1)";
691 case 0xFF06: return "Loop Back";
692 case 0x0007: return "Hot Reset (INACTIVE)";
693 case 0x0107: return "Hot Reset (HOT_RESET)";
694 case 0x0207: return "Hot Reset (MASTER_UP)";
695 case 0x0307: return "Hot Reset (MASTER_DOWN)";
696 case 0xFF07: return "Hot Reset";
697 case 0x0008: return "TxL0s (INACTIVE)";
698 case 0x0108: return "TxL0s (IDLE)";
699 case 0x0208: return "TxL0s (T0_L0)";
700 case 0x0308: return "TxL0s (FTS0)";
701 case 0x0408: return "TxL0s (FTS1)";
702 case 0xFF08: return "TxL0s";
703 case 0x0009: return "L1 (INACTIVE)";
704 case 0x0109: return "L1 (IDLE)";
705 case 0x0209: return "L1 (SUBSTATE)";
706 case 0x0309: return "L1 (SPD_CHG1)";
707 case 0x0409: return "L1 (T0_L0)";
708 case 0xFF09: return "L1";
709 case 0x000A: return "L2 (INACTIVE)";
710 case 0x010A: return "L2 (IDLE)";
711 case 0x020A: return "L2 (TX_WAKE0)";
712 case 0x030A: return "L2 (TX_WAKE1)";
713 case 0x040A: return "L2 (EXIT)";
714 case 0x050A: return "L2 (SPEED)";
715 case 0xFF0A: return "L2";
716 default: return "UNKNOWN";
717 }
718
719}
720
721/*********** EVENT Handling ***********/
722
728 SWITCHTEC_EVT_FLAG_CLEAR = 1 << 0,
729 SWITCHTEC_EVT_FLAG_EN_POLL = 1 << 1,
730 SWITCHTEC_EVT_FLAG_EN_LOG = 1 << 2,
731 SWITCHTEC_EVT_FLAG_EN_CLI = 1 << 3,
732 SWITCHTEC_EVT_FLAG_EN_FATAL = 1 << 4,
733 SWITCHTEC_EVT_FLAG_DIS_POLL = 1 << 5,
734 SWITCHTEC_EVT_FLAG_DIS_LOG = 1 << 6,
735 SWITCHTEC_EVT_FLAG_DIS_CLI = 1 << 7,
736 SWITCHTEC_EVT_FLAG_DIS_FATAL = 1 << 8,
737};
738
747 SWITCHTEC_EVT_IDX_LOCAL = -1,
748 SWITCHTEC_EVT_IDX_ALL = -2,
749};
750
756 SWITCHTEC_EVT_GLOBAL,
757 SWITCHTEC_EVT_PART,
758 SWITCHTEC_EVT_PFF,
759};
760
762 enum switchtec_event_id e,
763 int index);
765 enum switchtec_event_id e,
766 int index);
768 enum switchtec_event_id *e,
769 int *idx);
771 const char **name,
772 const char **desc);
773int switchtec_event_wait_for(struct switchtec_dev *dev,
774 enum switchtec_event_id e, int index,
775 struct switchtec_event_summary *res,
776 int timeout_ms);
777
778/******** FIRMWARE Management ********/
779
785 SWITCHTEC_DLSTAT_READY = 0x0,
786 SWITCHTEC_DLSTAT_INPROGRESS = 0x1,
787 SWITCHTEC_DLSTAT_HEADER_INCORRECT = 0x2,
788 SWITCHTEC_DLSTAT_OFFSET_INCORRECT = 0x3,
789 SWITCHTEC_DLSTAT_CRC_INCORRECT = 0x4,
790 SWITCHTEC_DLSTAT_LENGTH_INCORRECT = 0x5,
791 SWITCHTEC_DLSTAT_HARDWARE_ERR = 0x6,
792 SWITCHTEC_DLSTAT_COMPLETES = 0x7,
793 SWITCHTEC_DLSTAT_SUCCESS_FIRM_ACT = 0x8,
794 SWITCHTEC_DLSTAT_SUCCESS_DATA_ACT = 0x9,
795 SWITCHTEC_DLSTAT_PACKAGE_TOO_SMALL = 0xa,
796 SWITCHTEC_DLSTAT_SIG_MEM_ALLOC = 0xb,
797 SWITCHTEC_DLSTAT_SEEPROM = 0xc,
798 SWITCHTEC_DLSTAT_READONLY_PARTITION = 0xd,
799 SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT = 0xe,
800 SWITCHTEC_DLSTAT_SEEPROM_TWI_NOT_ENABLED = 0xf,
801 SWITCHTEC_DLSTAT_PROGRAM_RUNNING = 0x10,
802 SWITCHTEC_DLSTAT_NOT_ALLOWED = 0x11,
803 SWITCHTEC_DLSTAT_XML_MISMATCH_ACT = 0x12,
804 SWITCHTEC_DLSTAT_UNKNOWN_ACT = 0x13,
805
806 SWITCHTEC_DLSTAT_ERROR_PROGRAM = 0x1000,
807 SWITCHTEC_DLSTAT_ERROR_OFFSET = 0x1001,
808
809 SWITCHTEC_DLSTAT_NO_FILE = 0x7d009,
810};
811
816 SWITCHTEC_FW_RW = 0,
817 SWITCHTEC_FW_RO = 1,
818};
819
820enum switchtec_fw_redundancy {
821 SWITCHTEC_FW_REDUNDANCY_SET = 1,
822 SWITCHTEC_FW_REDUNDANCY_CLEAR = 0,
823};
824
825int switchtec_fw_toggle_active_partition(struct switchtec_dev *dev,
826 int toggle_bl2, int toggle_key,
827 int toggle_fw, int toggle_cfg);
828int switchtec_fw_setup_redundancy(struct switchtec_dev *dev,
829 enum switchtec_fw_redundancy redund,
830 enum switchtec_fw_type type);
831int switchtec_fw_write_fd(struct switchtec_dev *dev, int img_fd,
832 int dont_activate, int force,
833 void (*progress_callback)(int cur, int tot));
834int switchtec_fw_write_file(struct switchtec_dev *dev, FILE *fimg,
835 int dont_activate, int force,
836 void (*progress_callback)(int cur, int tot));
837int switchtec_fw_read_fd(struct switchtec_dev *dev, int fd,
838 unsigned long addr, size_t len,
839 void (*progress_callback)(int cur, int tot));
840int switchtec_fw_body_read_fd(struct switchtec_dev *dev, int fd,
841 struct switchtec_fw_image_info *info,
842 void (*progress_callback)(int cur, int tot));
843int switchtec_fw_read(struct switchtec_dev *dev, unsigned long addr,
844 size_t len, void *buf);
845void switchtec_fw_perror(const char *s, int ret);
846int switchtec_fw_file_info(int fd, struct switchtec_fw_image_info *info);
847int switchtec_fw_file_secure_version_newer(struct switchtec_dev *dev,
848 int img_fd);
849const char *switchtec_fw_image_type(const struct switchtec_fw_image_info *info);
851switchtec_fw_part_summary(struct switchtec_dev *dev);
854int switchtec_fw_is_boot_ro(struct switchtec_dev *dev);
855int switchtec_fw_set_boot_ro(struct switchtec_dev *dev,
856 enum switchtec_fw_ro ro);
857enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version);
858int switchtec_bind_info(struct switchtec_dev *dev,
859 struct switchtec_bind_status_out *bind_status,
860 int phy_port);
861int switchtec_bind(struct switchtec_dev *dev, int par_id,
862 int log_port, int phy_port);
863int switchtec_unbind(struct switchtec_dev *dev, int par_id, int log_port);
864bool switchtec_stack_bif_port_valid(struct switchtec_dev *dev, int stack_id,
865 int port_id);
866int switchtec_stack_bif_width(struct switchtec_dev *dev, int stack_id,
867 int port_bif);
868int switchtec_get_stack_bif(struct switchtec_dev *dev, int stack_id,
869 int port_bif[SWITCHTEC_PORTS_PER_STACK]);
870int switchtec_set_stack_bif(struct switchtec_dev *dev, int stack_id,
871 int port_bif[SWITCHTEC_PORTS_PER_STACK]);
872
873/********** EVENT COUNTER *********/
874
879 UNSUP_REQ_ERR = 1 << 0,
880 ECRC_ERR = 1 << 1,
882 RCVR_OFLOW_ERR = 1 << 3,
888 UNCOR_INT_ERR = 1 << 9,
891 BAD_DLLP = 1 << 12,
892 BAD_TLP = 1 << 13,
893 RCVR_ERR = 1 << 14,
894 RCV_FATAL_MSG = 1 << 15,
896 RCV_CORR_MSG = 1 << 17,
897 NAK_RCVD = 1 << 18,
898 RULE_TABLE_HIT = 1 << 19,
899 POSTED_TLP = 1 << 20,
900 COMP_TLP = 1 << 21,
901 NON_POSTED_TLP = 1 << 22,
902
917
921 ALL = (1 << 23) - 1,
922};
923
928extern const struct switchtec_evcntr_type_list {
930 const char *name;
931 const char *help;
933
938 unsigned port_mask; //<! Mask of ports this counter counts
939
942 int egress; //<! If 1, count egress, otherwise on ingress
943
948 unsigned threshold;
949};
950
952const char *switchtec_evcntr_type_str(int *type_mask);
953int switchtec_evcntr_setup(struct switchtec_dev *dev, unsigned stack_id,
954 unsigned cntr_id,
955 struct switchtec_evcntr_setup *setup);
956int switchtec_evcntr_get_setup(struct switchtec_dev *dev, unsigned stack_id,
957 unsigned cntr_id, unsigned nr_cntrs,
958 struct switchtec_evcntr_setup *res);
959int switchtec_evcntr_get(struct switchtec_dev *dev, unsigned stack_id,
960 unsigned cntr_id, unsigned nr_cntrs, unsigned *res,
961 int clear);
962int switchtec_evcntr_get_both(struct switchtec_dev *dev, unsigned stack_id,
963 unsigned cntr_id, unsigned nr_cntrs,
964 struct switchtec_evcntr_setup *setup,
965 unsigned *counts, int clear);
966int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms);
967
968/********** BANDWIDTH COUNTER *********/
969
974 uint64_t time_us;
976 uint64_t posted;
977 uint64_t comp;
978 uint64_t nonposted;
981};
982
983void switchtec_bwcntr_sub(struct switchtec_bwcntr_res *new_cntr,
984 struct switchtec_bwcntr_res *old_cntr);
985int switchtec_bwcntr_set_many(struct switchtec_dev *dev, int nr_ports,
986 int * phys_port_ids,
987 enum switchtec_bw_type bw_type);
988int switchtec_bwcntr_set_all(struct switchtec_dev *dev,
989 enum switchtec_bw_type bw_type);
990int switchtec_bwcntr_many(struct switchtec_dev *dev, int nr_ports,
991 int *phys_port_ids, int clear,
992 struct switchtec_bwcntr_res *res);
993int switchtec_bwcntr_all(struct switchtec_dev *dev, int clear,
994 struct switchtec_port_id **ports,
995 struct switchtec_bwcntr_res **res);
996uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d);
997
998/********** LATENCY COUNTER *********/
999
1000#define SWITCHTEC_LAT_ALL_INGRESS 63
1001
1002int switchtec_lat_setup_many(struct switchtec_dev *dev, int nr_ports,
1003 int *egress_port_ids, int *ingress_port_ids);
1004int switchtec_lat_setup(struct switchtec_dev *dev, int egress_port_id,
1005 int ingress_port_id, int clear);
1006int switchtec_lat_get_many(struct switchtec_dev *dev, int nr_ports,
1007 int clear, int *egress_port_ids,
1008 int *cur_ns, int *max_ns);
1009int switchtec_lat_get(struct switchtec_dev *dev, int clear,
1010 int egress_port_ids, int *cur_ns,
1011 int *max_ns);
1012
1013/********** GLOBAL ADDRESS SPACE ACCESS *********/
1014
1015/*
1016 * GAS map maps the hardware registers into user memory space.
1017 * Needless to say, this can be very dangerous and should only
1018 * be done if you know what you are doing. Any register accesses
1019 * that use this will remain unsupported by Microsemi unless it's
1020 * done within the switchtec user project or otherwise specified.
1021 */
1022
1023gasptr_t switchtec_gas_map(struct switchtec_dev *dev, int writeable,
1024 size_t *map_size);
1025void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map);
1026
1027/********** DIAGNOSTIC FUNCTIONS *********/
1028
1029#define SWITCHTEC_DIAG_CROSS_HAIR_ALL_LANES -1
1030#define SWITCHTEC_DIAG_CROSS_HAIR_MAX_LANES 64
1031
1032enum switchtec_diag_cross_hair_state {
1033 SWITCHTEC_DIAG_CROSS_HAIR_DISABLED = 0,
1034 SWITCHTEC_DIAG_CROSS_HAIR_RESVD,
1035 SWITCHTEC_DIAG_CROSS_HAIR_WAITING,
1036 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_RIGHT,
1037 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_RIGHT,
1038 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_RIGHT,
1039 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_LEFT,
1040 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_LEFT,
1041 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_LEFT,
1042 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_TOP_RIGHT,
1043 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_TOP_RIGHT,
1044 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_TOP_RIGHT,
1045 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_BOT_RIGHT,
1046 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_BOT_RIGHT,
1047 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_BOT_RIGHT,
1048 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_TOP_LEFT,
1049 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_TOP_LEFT,
1050 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_TOP_LEFT,
1051 SWITCHTEC_DIAG_CROSS_HAIR_FIRST_ERROR_BOT_LEFT,
1052 SWITCHTEC_DIAG_CROSS_HAIR_ERROR_FREE_BOT_LEFT,
1053 SWITCHTEC_DIAG_CROSS_HAIR_FINAL_BOT_LEFT,
1054 SWITCHTEC_DIAG_CROSS_HAIR_DONE,
1055 SWITCHTEC_DIAG_CROSS_HAIR_ERROR,
1056};
1057
1059 enum switchtec_diag_cross_hair_state state;
1060 int lane_id;
1061
1062 union {
1063 struct {
1064 /* Valid when state is Error */
1065 int prev_state;
1066 int x_pos;
1067 int y_pos;
1068 };
1069 /* Valid when state is DONE */
1070 struct {
1071 int eye_left_lim;
1072 int eye_right_lim;
1073 int eye_bot_left_lim;
1074 int eye_bot_right_lim;
1075 int eye_top_left_lim;
1076 int eye_top_right_lim;
1077 };
1078 };
1079};
1080
1082 int port_id;
1083 int lane_id;
1084 int ctle;
1085 int target_amplitude;
1086 int speculative_dfe;
1087 int dynamic_dfe[7];
1088};
1089
1091 int lane_cnt;
1092 struct {
1093 int pre;
1094 int post;
1095 } cursors[16];
1096};
1097
1099 int lane_id;
1100 int step_cnt;
1101
1102 struct {
1103 int pre_cursor;
1104 int post_cursor;
1105 int fom;
1106 int pre_cursor_up;
1107 int post_cursor_up;
1108 int error_status;
1109 int active_status;
1110 int speed;
1111 } steps[126];
1112};
1113
1115 int fs;
1116 int lf;
1117};
1118
1120 int ctle2_rx_mode;
1121 int dtclk_5;
1122 int dtclk_8_6;
1123 int dtclk_9;
1124};
1125
1127 const char *tag;
1128 const char *desc;
1129 bool reserved;
1130};
1131
1132enum switchtec_diag_eye_data_mode {
1133 SWITCHTEC_DIAG_EYE_RAW,
1134 SWITCHTEC_DIAG_EYE_RATIO,
1135};
1136
1137enum switchtec_diag_loopback_enable {
1138 SWITCHTEC_DIAG_LOOPBACK_RX_TO_TX = 1 << 0,
1139 SWITCHTEC_DIAG_LOOPBACK_TX_TO_RX = 1 << 1,
1140 SWITCHTEC_DIAG_LOOPBACK_LTSSM = 1 << 2,
1141};
1142
1143enum switchtec_diag_pattern {
1144 SWITCHTEC_DIAG_PATTERN_PRBS_7,
1145 SWITCHTEC_DIAG_PATTERN_PRBS_11,
1146 SWITCHTEC_DIAG_PATTERN_PRBS_23,
1147 SWITCHTEC_DIAG_PATTERN_PRBS_31,
1148 SWITCHTEC_DIAG_PATTERN_PRBS_9,
1149 SWITCHTEC_DIAG_PATTERN_PRBS_15,
1150 SWITCHTEC_DIAG_PATTERN_PRBS_DISABLED,
1151};
1152
1153enum switchtec_diag_ltssm_speed {
1154 SWITCHTEC_DIAG_LTSSM_GEN1 = 0,
1155 SWITCHTEC_DIAG_LTSSM_GEN2 = 1,
1156 SWITCHTEC_DIAG_LTSSM_GEN3 = 2,
1157 SWITCHTEC_DIAG_LTSSM_GEN4 = 3,
1158};
1159
1160enum switchtec_diag_end {
1161 SWITCHTEC_DIAG_LOCAL,
1162 SWITCHTEC_DIAG_FAR_END,
1163};
1164
1165enum switchtec_diag_link {
1166 SWITCHTEC_DIAG_LINK_CURRENT,
1167 SWITCHTEC_DIAG_LINK_PREVIOUS,
1168};
1169
1171 unsigned int timestamp;
1172 float link_rate;
1173 int link_state;
1174};
1175
1176int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id);
1177int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev);
1178int switchtec_diag_cross_hair_get(struct switchtec_dev *dev, int start_lane_id,
1179 int num_lanes, struct switchtec_diag_cross_hair *res);
1180
1181int switchtec_diag_eye_set_mode(struct switchtec_dev *dev,
1182 enum switchtec_diag_eye_data_mode mode);
1183int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4],
1184 struct range *x_range, struct range *y_range,
1185 int step_interval);
1186int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels,
1187 size_t pixel_cnt, int *lane_id);
1188int switchtec_diag_eye_cancel(struct switchtec_dev *dev);
1189
1190int switchtec_diag_loopback_set(struct switchtec_dev *dev, int port_id,
1191 int enable, enum switchtec_diag_ltssm_speed ltssm_speed);
1192int switchtec_diag_loopback_get(struct switchtec_dev *dev, int port_id,
1193 int *enabled, enum switchtec_diag_ltssm_speed *ltssm_speed);
1194int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
1195 enum switchtec_diag_pattern type);
1196int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
1197 enum switchtec_diag_pattern *type);
1198int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,
1199 enum switchtec_diag_pattern type);
1200int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id,
1201 int lane_id, enum switchtec_diag_pattern *type,
1202 unsigned long long *err_cnt);
1203int switchtec_diag_pattern_inject(struct switchtec_dev *dev, int port_id,
1204 unsigned int err_cnt);
1205
1206int switchtec_diag_rcvr_obj(struct switchtec_dev *dev, int port_id,
1207 int lane_id, enum switchtec_diag_link link,
1208 struct switchtec_rcvr_obj *res);
1209int switchtec_diag_rcvr_ext(struct switchtec_dev *dev, int port_id,
1210 int lane_id, enum switchtec_diag_link link,
1211 struct switchtec_rcvr_ext *res);
1212
1213int switchtec_diag_port_eq_tx_coeff(struct switchtec_dev *dev, int port_id,
1214 enum switchtec_diag_end end, enum switchtec_diag_link link,
1215 struct switchtec_port_eq_coeff *res);
1216int switchtec_diag_port_eq_tx_table(struct switchtec_dev *dev, int port_id,
1217 enum switchtec_diag_link link,
1218 struct switchtec_port_eq_table *res);
1219int switchtec_diag_port_eq_tx_fslf(struct switchtec_dev *dev, int port_id,
1220 int lane_id, enum switchtec_diag_end end,
1221 enum switchtec_diag_link link,
1222 struct switchtec_port_eq_tx_fslf *res);
1223
1224int switchtec_diag_perm_table(struct switchtec_dev *dev,
1225 struct switchtec_mrpc table[MRPC_MAX_ID]);
1226int switchtec_diag_refclk_ctl(struct switchtec_dev *dev, int stack_id, bool en);
1227int switchtec_diag_ltssm_log(struct switchtec_dev *dev,
1228 int port, int *log_count,
1229 struct switchtec_diag_ltssm_log *log_data);
1230
1231#ifdef __cplusplus
1232}
1233#endif
1234
1235#endif
struct switchtec_dev * switchtec_open(const char *device)
Open a Switchtec device by string.
Definition: switchtec.c:253
void switchtec_list_free(struct switchtec_device_info *devlist)
Free a list of device info structures allocated by switchtec_list()
Definition: switchtec.c:231
struct switchtec_dev * switchtec_open_uart(int fd)
Open a switchtec device behind a uart device.
int switchtec_list(struct switchtec_device_info **devlist)
List all the switchtec devices in the system.
struct switchtec_dev * switchtec_open_by_index(int index)
Open a switchtec device by index.
int switchtec_cmd(struct switchtec_dev *dev, uint32_t cmd, const void *payload, size_t payload_len, void *resp, size_t resp_len)
Execute an MRPC command.
Definition: platform.c:164
void switchtec_close(struct switchtec_dev *dev)
Close a Switchtec device handle.
Definition: platform.c:101
void switchtec_perror(const char *str)
Print an error string to stdout.
Definition: switchtec.c:733
struct switchtec_dev * switchtec_open_i2c(const char *path, int i2c_addr)
Open a switchtec device behind an I2C device.
void switchtec_status_free(struct switchtec_status *status, int ports)
Free a list of status structures allocated by switchtec_status()
Definition: switchtec.c:571
struct switchtec_dev * switchtec_open_by_path(const char *path)
Open a switchtec device by path.
_PURE const char * switchtec_name(struct switchtec_dev *dev)
Get the string that was used to open the deviec.
Definition: switchtec.c:386
const char * switchtec_strerror(void)
Return a message coresponding to the last error.
Definition: switchtec.c:610
struct switchtec_dev * switchtec_open_eth(const char *ip, const int inst)
Open a switchtec device over ethernet.
int switchtec_get_devices(struct switchtec_dev *dev, struct switchtec_status *status, int ports)
Populate an already retrieved switchtec_status structure list with information about the devices plug...
Definition: platform.c:194
_PURE int switchtec_partition(struct switchtec_dev *dev)
Get the partiton number of the device that was opened.
Definition: switchtec.c:396
int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf, size_t buflen)
Get the firmware version as a user readable string.
Definition: platform.c:125
struct switchtec_dev * switchtec_open_by_pci_addr(int domain, int bus, int device, int func)
Open a switchtec device by PCI address (BDF)
int switchtec_event_ctl(struct switchtec_dev *dev, enum switchtec_event_id e, int index, int flags, uint32_t data[5])
Enable, disable and clear events or retrieve event data.
Definition: platform.c:313
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
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
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_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_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_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
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
enum switchtec_gen switchtec_fw_version_to_gen(unsigned int version)
Extract generation information from FW version number.
Definition: fw.c:397
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
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:1390
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:1483
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_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
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:1434
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
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_file_info(int fd, struct switchtec_fw_image_info *info)
Retrieve information about a firmware image file.
Definition: fw.c:740
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
void switchtec_fw_perror(const char *s, int ret)
Print an error string to stdout.
Definition: fw.c:521
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:1606
void switchtec_fw_part_summary_free(struct switchtec_fw_part_summary *summary)
Free a firmware part summary data structure.
Definition: fw.c:1372
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_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
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
void switchtec_gas_unmap(struct switchtec_dev *dev, gasptr_t map)
Unmap the GAS region mapped with.
Definition: platform.c:267
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:2054
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:1991
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:1451
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
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:1532
float switchtec_die_temp(struct switchtec_dev *dev)
Get the die temperature of the switchtec device.
Definition: switchtec.c:1777
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:2079
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:2038
int switchtec_hard_reset(struct switchtec_dev *dev)
Perform an MRPC hard reset command.
Definition: switchtec.c:780
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
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:1644
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:1722
int switchtec_echo(struct switchtec_dev *dev, uint32_t input, uint32_t *output)
Perform an MRPC echo command.
Definition: switchtec.c:764
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:2123
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:1887
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:1927
const char * switchtec_evcntr_type_str(int *type_mask)
Get a string for the event indicated by lowest bit set in the type_mask.
Definition: pmon.c:116
int switchtec_evcntr_type_count(void)
Get the number of event counter types.
Definition: pmon.c:95
int switchtec_lat_get(struct switchtec_dev *dev, int clear, int egress_port_ids, int *cur_ns, int *max_ns)
Get a single latency counter result.
Definition: pmon.c:633
void switchtec_bwcntr_sub(struct switchtec_bwcntr_res *new_cntr, struct switchtec_bwcntr_res *old_cntr)
Subtract all the values between two bwcntr result structures.
Definition: pmon.c:339
int switchtec_bwcntr_set_all(struct switchtec_dev *dev, enum switchtec_bw_type bw_type)
Set bandwidth type for all the ports in the system.
Definition: pmon.c:387
int switchtec_evcntr_wait(struct switchtec_dev *dev, int timeout_ms)
Block until any event counter has reached its threshold.
Definition: pmon.c:325
int switchtec_evcntr_get_both(struct switchtec_dev *dev, unsigned stack_id, unsigned cntr_id, unsigned nr_cntrs, struct switchtec_evcntr_setup *setup, unsigned *counts, int clear)
Retrieve the current counts and setup information for one or more event counters.
Definition: pmon.c:301
int switchtec_lat_setup(struct switchtec_dev *dev, int egress_port_id, int ingress_port_id, int clear)
Setup a latency counter.
Definition: pmon.c:557
int switchtec_bwcntr_many(struct switchtec_dev *dev, int nr_ports, int *phys_port_ids, int clear, struct switchtec_bwcntr_res *res)
Retrieve the bandwidth counter results for a number of ports.
Definition: pmon.c:419
int switchtec_bwcntr_all(struct switchtec_dev *dev, int clear, struct switchtec_port_id **ports, struct switchtec_bwcntr_res **res)
Retrieve the bandwidth counter results for all the ports in the system.
Definition: pmon.c:473
uint64_t switchtec_bwcntr_tot(struct switchtec_bwcntr_dir *d)
Get the total.
Definition: pmon.c:513
int switchtec_lat_get_many(struct switchtec_dev *dev, int nr_ports, int clear, int *egress_port_ids, int *cur_ns, int *max_ns)
Get a number of latency counter results.
Definition: pmon.c:585
int switchtec_lat_setup_many(struct switchtec_dev *dev, int nr_ports, int *egress_port_ids, int *ingress_port_ids)
Setup a number of latency counters.
Definition: pmon.c:527
int switchtec_evcntr_get(struct switchtec_dev *dev, unsigned stack_id, unsigned cntr_id, unsigned nr_cntrs, unsigned *res, int clear)
Retrieve the current counts for one or more event counters.
Definition: pmon.c:257
int switchtec_bwcntr_set_many(struct switchtec_dev *dev, int nr_ports, int *phys_port_ids, enum switchtec_bw_type bw_type)
Set bandwidth type for a number of ports.
Definition: pmon.c:359
int switchtec_evcntr_get_setup(struct switchtec_dev *dev, unsigned stack_id, unsigned cntr_id, unsigned nr_cntrs, struct switchtec_evcntr_setup *res)
Retrieve the setup information for one or more event counters.
Definition: pmon.c:214
Definition: utils.h:34
uint64_t comp
Completion TLP bytes.
Definition: switchtec.h:977
uint64_t posted
Posted TLP bytes.
Definition: switchtec.h:976
uint64_t nonposted
Non-Posted TLP bytes.
Definition: switchtec.h:978
Bandwidth counter result struct.
Definition: switchtec.h:973
struct switchtec_bwcntr_res::switchtec_bwcntr_dir ingress
Bandwidth into the port.
uint64_t time_us
Time (in microseconds)
Definition: switchtec.h:974
struct switchtec_bwcntr_res::switchtec_bwcntr_dir egress
Bandwidth out of the port.
Switchtec device id to generation/variant mapping.
Definition: switchtec.c:80
Represents a Switchtec device in the switchtec_list() function.
Definition: switchtec.h:131
char fw_version[32]
Firmware version.
Definition: switchtec.h:137
char pci_dev[256]
PCI BDF string.
Definition: switchtec.h:134
char desc[256]
Device description, if available.
Definition: switchtec.h:133
char path[PATH_MAX]
Path to the device.
Definition: switchtec.h:138
char name[256]
Device name, eg. switchtec0.
Definition: switchtec.h:132
char product_id[32]
Product ID.
Definition: switchtec.h:135
char product_rev[8]
Product revision.
Definition: switchtec.h:136
Structure used to setup an event counter.
Definition: switchtec.h:937
unsigned threshold
Threshold to count to before generating an interrupt.
Definition: switchtec.h:948
enum switchtec_evcntr_type_mask type_mask
Event counter types to count.
Definition: switchtec.h:941
Null-terminated list of all event counter types with a name and help text.
Definition: switchtec.h:928
Event summary bitmaps.
Definition: switchtec.h:289
uint64_t part_bitmap
Bitmap of partitions with active events.
Definition: switchtec.h:291
uint64_t global
Bitmap of global events.
Definition: switchtec.h:290
unsigned part[SWITCHTEC_MAX_PARTS]
Bitmap of events in each partition.
Definition: switchtec.h:295
unsigned local_part
Bitmap of events in the local partition.
Definition: switchtec.h:292
unsigned pff[SWITCHTEC_MAX_PFF_CSR]
Bitmap of events in each port function.
Definition: switchtec.h:298
Information about a firmware image or partition.
Definition: switchtec.h:251
enum switchtec_gen gen
Image generation.
Definition: switchtec.h:252
size_t part_body_offset
Partition image body offset.
Definition: switchtec.h:258
unsigned long image_crc
CRC checksum of the image.
Definition: switchtec.h:260
char version[32]
Firmware/Config version.
Definition: switchtec.h:255
size_t image_len
Length of the image.
Definition: switchtec.h:259
unsigned long part_id
Image partition ID.
Definition: switchtec.h:253
size_t part_addr
Address of the partition.
Definition: switchtec.h:256
size_t part_len
Length of the partition.
Definition: switchtec.h:257
enum switchtec_fw_type type
Image partition type.
Definition: switchtec.h:254
Information about log file and log definition file.
Definition: switchtec.h:217
Port identification.
Definition: switchtec.h:144
unsigned char upstream
1 if this is an upstream port
Definition: switchtec.h:148
unsigned char partition
Partition the port is in.
Definition: switchtec.h:145
unsigned char stk_id
Port number within the stack.
Definition: switchtec.h:149
unsigned char log_id
Logical port number.
Definition: switchtec.h:151
unsigned char phys_id
Physical port number.
Definition: switchtec.h:150
unsigned char stack
Stack number.
Definition: switchtec.h:147
Port status structure.
Definition: switchtec.h:160
struct switchtec_port_id port
Port ID.
Definition: switchtec.h:161
unsigned char link_up
1 if the link is up
Definition: switchtec.h:164
unsigned char lane_reversal
Lane reversal.
Definition: switchtec.h:168
unsigned int acs_ctrl
ACS Setting of the Port.
Definition: switchtec.h:180
const char * lane_reversal_str
Lane reversal as a string.
Definition: switchtec.h:169
unsigned char cfg_lnk_width
Configured link width.
Definition: switchtec.h:162
unsigned char link_rate
Link rate/gen.
Definition: switchtec.h:165
unsigned char first_act_lane
First active lane.
Definition: switchtec.h:170
int vendor_id
Vendor ID.
Definition: switchtec.h:177
unsigned char neg_lnk_width
Negotiated link width.
Definition: switchtec.h:163
uint16_t ltssm
Link state.
Definition: switchtec.h:166
char * pci_bdf_path
PCI BDF path of the port.
Definition: switchtec.h:174
char * pci_bdf
PCI BDF of the port.
Definition: switchtec.h:173
int device_id
Device ID.
Definition: switchtec.h:178
char * class_devices
Comma seperated list of classes.
Definition: switchtec.h:179
char * pci_dev
PCI BDF of the device on the port.
Definition: switchtec.h:176
const char * ltssm_str
Link state as a string.
Definition: switchtec.h:167
switchtec_bw_type
The types of bandwidth.
Definition: switchtec.h:186
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_pfxl(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-L.
Definition: switchtec.h:464
switchtec_log_parse_type
Log types to parse.
Definition: switchtec.h:209
int switchtec_diag_cross_hair_disable(struct switchtec_dev *dev)
Disable active cross hair.
Definition: diag.c:69
switchtec_event_id
Enumeration of all possible events.
Definition: switchtec.h:304
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
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 int switchtec_is_psxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX-A.
Definition: switchtec.h:507
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_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
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_ro
Flag which indicates if a partition is read-only or not.
Definition: switchtec.h:815
switchtec_rev
Device hardware revision.
Definition: switchtec.h:96
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
static int switchtec_is_psx_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX or PSX.
Definition: switchtec.h:524
switchtec_evcntr_type_mask
Event counter type mask (may be or-d together)
Definition: switchtec.h:878
@ ALL_TLPS
Mask indicating all TLP types.
Definition: switchtec.h:916
@ RCVR_ERR
Receiver Error.
Definition: switchtec.h:893
@ RCVR_OFLOW_ERR
Receiver Overflow Error.
Definition: switchtec.h:882
@ REPLAY_NUM_ROLLOVER
Replay Number Rollover.
Definition: switchtec.h:890
@ COMP_TLP
Completion TLP.
Definition: switchtec.h:900
@ BAD_TLP
Bad TLP.
Definition: switchtec.h:892
@ NON_POSTED_TLP
Non-Posted TLP.
Definition: switchtec.h:901
@ BAD_DLLP
Bad DLLP.
Definition: switchtec.h:891
@ SURPRISE_DOWN_ERR
Surprise Down Error.
Definition: switchtec.h:885
@ POISONED_TLP_ERR
Poisoned TLP Error.
Definition: switchtec.h:884
@ ALL_ERRORS
Mask indicating all possible errors.
Definition: switchtec.h:906
@ RCV_CORR_MSG
Receive Correctable Error Message.
Definition: switchtec.h:896
@ RCV_NON_FATAL_MSG
Receive Non-FATAL Error Message.
Definition: switchtec.h:895
@ NAK_RCVD
NAK Received.
Definition: switchtec.h:897
@ UNSUP_REQ_ERR
Unsupported Request Error.
Definition: switchtec.h:879
@ POSTED_TLP
Posted TLP.
Definition: switchtec.h:899
@ RULE_TABLE_HIT
Rule Search Table Rule Hit.
Definition: switchtec.h:898
@ ALL
Mask indicating all event types.
Definition: switchtec.h:921
@ ECRC_ERR
ECRC Error.
Definition: switchtec.h:880
@ REPLAY_TMR_TIMEOUT
Replay Timer Timeout.
Definition: switchtec.h:889
@ HDR_LOG_OFLOW_ERR
Header Log Overflow Error.
Definition: switchtec.h:887
@ DATA_LINK_PROTO_ERR
Data Link Protocol Error.
Definition: switchtec.h:886
@ UNCOR_INT_ERR
Uncorrectable Internal Error.
Definition: switchtec.h:888
@ CMPLTR_ABORT_ERR
Completer Abort Error.
Definition: switchtec.h:883
@ RCV_FATAL_MSG
Receive FATAL Error Message.
Definition: switchtec.h:894
@ MALFORM_TLP_ERR
Malformed TLP Error.
Definition: switchtec.h:881
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
static const char * switchtec_rev_str(enum switchtec_rev rev)
Return the revision string.
Definition: switchtec.h:570
static const char * switchtec_gen_str(struct switchtec_dev *dev)
Return the generation string of a Switchtec device.
Definition: switchtec.h:556
static int switchtec_is_pfxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-A.
Definition: switchtec.h:480
static int switchtec_is_pfx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX(L/I/A).
Definition: switchtec.h:488
static int switchtec_is_pfxi(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX-I.
Definition: switchtec.h:472
switchtec_gen
The PCIe generations.
Definition: switchtec.h:86
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
static int switchtec_is_psx(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX.
Definition: switchtec.h:499
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
int switchtec_diag_perm_table(struct switchtec_dev *dev, struct switchtec_mrpc table[MRPC_MAX_ID])
Get the permission table.
Definition: diag.c:862
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_log_def_type
Log definition data types.
Definition: switchtec.h:231
__gas struct switchtec_gas * gasptr_t
Shortform for a pointer to the GAS register space.
Definition: switchtec.h:80
switchtec_variant
The variant types of Switchtec device.
Definition: switchtec.h:116
int switchtec_diag_cross_hair_enable(struct switchtec_dev *dev, int lane_id)
Enable cross hair on specified lane.
Definition: diag.c:52
switchtec_event_type
There are three event types indicated by this enumeration: global, partition and port function.
Definition: switchtec.h:755
switchtec_log_type
Describe the type of logs too dump.
Definition: switchtec.h:195
switchtec_event_special
Special event indexes numbers.
Definition: switchtec.h:746
switchtec_boot_phase
Device boot phase.
Definition: switchtec.h:106
static const float switchtec_gen_transfers[]
Number of GT/s capable for each PCI generation or link_rate.
Definition: switchtec.h:615
int switchtec_diag_eye_cancel(struct switchtec_dev *dev)
Cancel in-progress eye capture.
Definition: diag.c:306
static int switchtec_is_gen4(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 4 device.
Definition: switchtec.h:431
static int switchtec_is_paxa(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX-A.
Definition: switchtec.h:540
static int switchtec_max_supported_ports(struct switchtec_dev *dev)
Return the max number of ports of a Switchtec device.
Definition: switchtec.h:447
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
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
static int switchtec_is_pax(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX.
Definition: switchtec.h:532
static int switchtec_is_psx_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PSX(A).
Definition: switchtec.h:515
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
static int switchtec_is_gen5(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 5 device.
Definition: switchtec.h:439
static int switchtec_is_pfx(struct switchtec_dev *dev)
Return whether a Switchtec device is PFX.
Definition: switchtec.h:456
switchtec_event_flags
Event control flags.
Definition: switchtec.h:727
switchtec_fw_dlstatus
Firmware update status.
Definition: switchtec.h:784
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
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:585
static const float switchtec_gen_datarate[]
Number of GB/s capable for each PCI generation or link_rate.
Definition: switchtec.h:617
static int switchtec_is_pax_all(struct switchtec_dev *dev)
Return whether a Switchtec device is PAX(A).
Definition: switchtec.h:548
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
static const char * switchtec_variant_str(struct switchtec_dev *dev)
Return the variant string of a Switchtec device.
Definition: switchtec.h:598
static int switchtec_is_gen3(struct switchtec_dev *dev)
Return whether a Switchtec device is a Gen 3 device.
Definition: switchtec.h:423