25#ifndef LIBSWITCHTEC_FABRIC_H
26#define LIBSWITCHTEC_FABRIC_H
94int switchtec_topo_info_dump(
struct switchtec_dev *dev,
99#define SWITCHTEC_FABRIC_MULTI_FUNC_NUM 8
103 uint8_t host_phys_port_id;
104 uint8_t host_log_port_id;
106 uint16_t ep_pdfid[SWITCHTEC_FABRIC_MULTI_FUNC_NUM];
111 uint8_t host_phys_port_id;
112 uint8_t host_log_port_id;
117int switchtec_gfms_bind(
struct switchtec_dev *dev,
119int switchtec_gfms_unbind(
struct switchtec_dev *dev,
124enum switchtec_fabric_port_control_type {
125 SWITCTEC_PORT_CONTROL_DISABLE,
126 SWITCTEC_PORT_CONTROL_ENABLE,
127 SWITCTEC_PORT_CONTROL_LINK_RETRAIN,
128 SWITCTEC_PORT_CONTROL_LINK_HOT_RESET,
131enum switchtec_fabric_hot_reset_flag {
132 SWITCTEC_PORT_CONTROL_HOT_RESET_STATUS_CLEAR,
133 SWITCTEC_PORT_CONTROL_HOT_RESET_STATUS_SET,
136int switchtec_port_control(
struct switchtec_dev *dev, uint8_t control_type,
137 uint8_t phys_port_id, uint8_t hot_reset_flag);
144enum switchtec_fab_port_type {
145 SWITCHTEC_FAB_PORT_TYPE_UNUSED,
146 SWITCHTEC_FAB_PORT_TYPE_FABRIC,
147 SWITCHTEC_FAB_PORT_TYPE_FABRIC_EP,
148 SWITCHTEC_FAB_PORT_TYPE_FABRIC_HOST,
149 SWITCHTEC_FAB_PORT_TYPE_INVALID,
155enum switchtec_fab_port_clock_sris {
156 SWITCHTEC_FAB_PORT_CLOCK_SRIS_DISABLE,
157 SWITCHTEC_FAB_PORT_CLOCK_SRIS_ENABLE,
158 SWITCHTEC_FAB_PORT_CLOCK_SRIS_INVALID,
171int switchtec_fab_port_config_get(
struct switchtec_dev *dev,
172 uint8_t phys_port_id,
174int switchtec_fab_port_config_set(
struct switchtec_dev *dev,
175 uint8_t phys_port_id,
180#define SWITCHTEC_FABRIC_MAX_SWITCH_NUM 16
181#define SWITCHTEC_FABRIC_MAX_HOST_PER_SWITCH 16
182#define SWITCHTEC_FABRIC_MAX_DEV_PER_SWITCH 32
183#define SWITCHTEC_FABRIC_MAX_FUNC_PER_DEV 32
184#define SWITCHTEC_FABRIC_MAX_BAR_NUM 6
185#define SWITCHTEC_FABRIC_MAX_DSP_PER_HOST 32
186#define SWITCHTEC_FABRIC_MAX_BINDING_NUM 512
188enum switchtec_gfms_db_ep_attached_device_type {
189 SWITCHTEC_GFMS_DB_TYPE_EP,
190 SWITCHTEC_GFMS_DB_TYPE_SWITCH,
191 SWITCHTEC_GFMS_DB_TYPE_NON,
194enum switchtec_gfms_db_reach_type {
195 SWITCHTEC_GFMS_DB_REACH_UC,
196 SWITCHTEC_GFMS_DB_REACH_BC,
197 SWITCHTEC_GFMS_DB_REACH_UR,
200enum switchtec_gfms_db_hvd_usp_link_state {
201 SWITCHTEC_GFMS_DB_HVD_USP_LINK_DOWN,
202 SWITCHTEC_GFMS_DB_HVD_USP_LINK_UP,
205enum switchtec_gfms_db_vep_type {
206 SWITCHTEC_GFMS_DB_VEP_TYPE_MGMT = 6,
209enum switchtec_gfms_db_ep_port_bar_type {
210 SWITCHTEC_GFMS_DB_EP_BAR_TYPE_MEM_32_PREFETCH = 0x8,
211 SWITCHTEC_GFMS_DB_EP_BAR_TYPE_MEM_64_PREFETCH = 0xc,
212 SWITCHTEC_GFMS_DB_EP_BAR_TYPE_MEM_32_NON_PREFETCH = 0x0,
213 SWITCHTEC_GFMS_DB_EP_BAR_TYPE_MEM_64_NON_PREFETCH = 0x4,
214 SWITCHTEC_GFMS_DB_EP_BAR_TYPE_IO_32_PREFETCH = 0x9,
215 SWITCHTEC_GFMS_DB_EP_BAR_TYPE_IO_64_PREFETCH = 0xd,
216 SWITCHTEC_GFMS_DB_EP_BAR_TYPE_IO_32_NON_PREFETCH = 0x1,
217 SWITCHTEC_GFMS_DB_EP_BAR_TYPE_IO_64_NON_PREFETCH = 0x5,
221 uint8_t section_class;
224 uint32_t resp_size_dw;
232 uint8_t reachable_type;
243 uint8_t phy_port_count;
246 uint16_t ep_function_count;
253 uint16_t vdfid_start;
255 uint16_t pdfid_start;
257 uint32_t rc_port_map_low;
258 uint32_t rc_port_map_high;
259 uint32_t ep_port_map_low;
260 uint32_t ep_port_map_high;
261 uint32_t fab_port_map_low;
262 uint32_t fab_port_map_high;
263 uint32_t free_port_map_low;
264 uint32_t free_port_map_high;
276 uint16_t logical_port_count;
281 uint16_t bound_pdfid;
282 } bound[SWITCHTEC_FABRIC_MULTI_FUNC_NUM *
283 SWITCHTEC_FABRIC_MAX_DSP_PER_HOST];
295 SWITCHTEC_FABRIC_MAX_HOST_PER_SWITCH];
302 uint16_t bound_pdfid;
303 uint16_t bound_hvd_bdf;
319 uint16_t log_dsp_count;
322 log_port_region[SWITCHTEC_FABRIC_MULTI_FUNC_NUM *
323 SWITCHTEC_FABRIC_MAX_DSP_PER_HOST];
325 uint32_t log_port_p2p_enable_bitmap_low;
326 uint32_t log_port_p2p_enable_bitmap_high;
327 uint8_t log_port_count;
329 uint32_t config_bitmap_low;
330 uint32_t config_bitmap_high;
331 uint32_t active_bitmap_low;
332 uint32_t active_bitmap_high;
333 } log_port_p2p_bitmap[SWITCHTEC_FABRIC_MAX_DSP_PER_HOST];
344 uint8_t attached_phy_pid;
345 uint8_t attached_sw_idx;
346 uint16_t attached_swfid;
347 uint32_t attached_fw_version;
359 uint8_t sriov_cap_pf;
363 uint8_t bound_pax_id;
364 uint8_t bound_hvd_phy_pid;
365 uint8_t bound_hvd_log_pid;
368 uint16_t sub_sys_vid;
369 uint16_t sub_sys_did;
370 uint32_t device_class: 24;
371 uint32_t bar_number: 8;
385 uint32_t device_class: 24;
394 uint16_t function_number;
395 uint16_t attached_dsp_enumid;
396 uint32_t size_dw: 24;
403 functions[SWITCHTEC_FABRIC_MAX_FUNC_PER_DEV];
411 SWITCHTEC_FABRIC_MAX_HOST_PER_SWITCH +
412 SWITCHTEC_FABRIC_MAX_DEV_PER_SWITCH];
416 switch_eps[SWITCHTEC_FABRIC_MAX_DEV_PER_SWITCH];
423 uint32_t size_dw: 24;
444 SWITCHTEC_FABRIC_MAX_DEV_PER_SWITCH];
454static inline int switchtec_ep_port_bar_type_str(uint8_t bar_type,
459 case SWITCHTEC_GFMS_DB_EP_BAR_TYPE_MEM_32_PREFETCH:
460 strncpy(bar_type_str,
"Memory, Prefetchable, 32-bit", len);
462 case SWITCHTEC_GFMS_DB_EP_BAR_TYPE_MEM_64_PREFETCH:
463 strncpy(bar_type_str,
"Memory, Prefetchable, 64-bit", len);
465 case SWITCHTEC_GFMS_DB_EP_BAR_TYPE_MEM_32_NON_PREFETCH:
466 strncpy(bar_type_str,
"Memory, Non-prefetchable, 32-bit", len);
468 case SWITCHTEC_GFMS_DB_EP_BAR_TYPE_MEM_64_NON_PREFETCH:
469 strncpy(bar_type_str,
"Memory, Non-prefetchable, 64-bit", len);
471 case SWITCHTEC_GFMS_DB_EP_BAR_TYPE_IO_32_PREFETCH:
472 strncpy(bar_type_str,
"IO, Prefetchable, 32-bit", len);
474 case SWITCHTEC_GFMS_DB_EP_BAR_TYPE_IO_64_PREFETCH:
475 strncpy(bar_type_str,
"IO, Prefetchable, 64-bit", len);
477 case SWITCHTEC_GFMS_DB_EP_BAR_TYPE_IO_32_NON_PREFETCH:
478 strncpy(bar_type_str,
"IO, Non-prefetchable, 32-bit", len);
480 case SWITCHTEC_GFMS_DB_EP_BAR_TYPE_IO_64_NON_PREFETCH:
481 strncpy(bar_type_str,
"IO, Non-prefetchable, 64-bit", len);
484 strncpy(bar_type_str,
"Unknown", len);
487 bar_type_str[len - 1] =
'\0';
491int switchtec_fab_gfms_db_dump_fabric_general(
492 struct switchtec_dev *dev,
494int switchtec_fab_gfms_db_dump_pax_all(
495 struct switchtec_dev *dev,
497int switchtec_fab_gfms_db_dump_pax_general(
498 struct switchtec_dev *dev,
500int switchtec_fab_gfms_db_dump_hvd(
struct switchtec_dev *dev,
503int switchtec_fab_gfms_db_dump_fab_port(
504 struct switchtec_dev *dev,
507int switchtec_fab_gfms_db_dump_ep_port(
508 struct switchtec_dev *dev,
511int switchtec_fab_gfms_db_dump_hvd_detail(
512 struct switchtec_dev *dev,
521enum switchtec_gfms_event_type {
522 SWITCHTEC_GFMS_EVENT_HOST_LINK_UP = 0,
523 SWITCHTEC_GFMS_EVENT_HOST_LINK_DOWN = 1,
524 SWITCHTEC_GFMS_EVENT_DEV_ADD = 2,
525 SWITCHTEC_GFMS_EVENT_DEV_DEL = 3,
526 SWITCHTEC_GFMS_EVENT_FAB_LINK_UP = 4,
527 SWITCHTEC_GFMS_EVENT_FAB_LINK_DOWN = 5,
528 SWITCHTEC_GFMS_EVENT_BIND = 6,
529 SWITCHTEC_GFMS_EVENT_UNBIND = 7,
530 SWITCHTEC_GFMS_EVENT_DATABASE_CHANGED = 8,
531 SWITCHTEC_GFMS_EVENT_HVD_INST_ENABLE = 9,
532 SWITCHTEC_GFMS_EVENT_HVD_INST_DISABLE = 10,
533 SWITCHTEC_GFMS_EVENT_EP_PORT_REMOVE = 11,
534 SWITCHTEC_GFMS_EVENT_EP_PORT_ADD = 12,
535 SWITCHTEC_GFMS_EVENT_AER = 13,
536 SWITCHTEC_GFMS_EVENT_MAX = 14
543 uint16_t phys_port_id;
550 uint16_t phys_port_id;
551 uint16_t function_count;
559 uint8_t host_phys_port_id;
570 uint8_t phys_port_id;
578 uint8_t phys_port_id;
585 uint16_t phys_port_id;
588 uint32_t ce_ue_err_sts;
589 uint32_t aer_err_log_time_stamp_high;
590 uint32_t aer_err_log_time_stamp_low;
591 uint32_t aer_header_log[4];
594#define switchtec_gfms_aer_log(aer) (((aer)->handle) & 0x01)
596#define switchtec_gfms_aer_dpc(aer) (((aer)->handle) & 0x02)
598#define switchtec_gfms_aer_ce_ue(aer) (((aer)->handle) & 0x04)
617int switchtec_get_gfms_events(
struct switchtec_dev *dev,
619 size_t elist_len,
int *overflow,
620 size_t *remain_number);
622int switchtec_clear_gfms_events(
struct switchtec_dev *dev);
625#define SWITCHTEC_DEVICE_MANAGE_MAX_RESP 1016
629 uint16_t expected_rsp_len;
639 uint8_t cmd_data[MRPC_MAX_DATA_LEN -
645 uint8_t rsp_data[SWITCHTEC_DEVICE_MANAGE_MAX_RESP];
648int switchtec_device_manage(
struct switchtec_dev *dev,
653enum switchtec_ep_tunnel_status{
654 SWITCHTEC_EP_TUNNEL_DISABLED = 0,
655 SWITCHTEC_EP_TUNNEL_ENABLED = 1,
658int switchtec_ep_tunnel_config(
struct switchtec_dev *dev, uint16_t subcmd,
659 uint16_t pdfid, uint16_t expected_rsp_len,
660 uint8_t *meta_data, uint16_t meta_data_len,
662int switchtec_ep_tunnel_enable(
struct switchtec_dev *dev, uint16_t pdfid);
663int switchtec_ep_tunnel_disable(
struct switchtec_dev *dev, uint16_t pdfid);
664int switchtec_ep_tunnel_status(
struct switchtec_dev *dev, uint16_t pdfid,
668#define SWITCHTEC_EP_CSR_MAX_READ_LEN 4
669#define SWITCHTEC_EP_CSR_MAX_WRITE_LEN 4
670#define SWITCHTEC_EP_BAR_MAX_READ_LEN SWITCHTEC_MRPC_PAYLOAD_SIZE
671#define SWITCHTEC_EP_BAR_MAX_WRITE_LEN 128
673int switchtec_ep_csr_read8(
struct switchtec_dev *dev, uint16_t pdfid,
674 uint16_t addr, uint8_t *val);
675int switchtec_ep_csr_read16(
struct switchtec_dev *dev, uint16_t pdfid,
676 uint16_t addr, uint16_t *val);
677int switchtec_ep_csr_read32(
struct switchtec_dev *dev, uint16_t pdfid,
678 uint16_t addr, uint32_t *val);
680int switchtec_ep_csr_write8(
struct switchtec_dev *dev, uint16_t pdfid,
681 uint8_t val, uint16_t addr);
682int switchtec_ep_csr_write16(
struct switchtec_dev *dev, uint16_t pdfid,
683 uint16_t val, uint16_t addr);
684int switchtec_ep_csr_write32(
struct switchtec_dev *dev, uint16_t pdfid,
685 uint32_t val, uint16_t addr);
687int switchtec_ep_bar_read8(
struct switchtec_dev *dev, uint16_t pdfid,
688 uint8_t bar_index, uint64_t addr, uint8_t *val);
689int switchtec_ep_bar_read16(
struct switchtec_dev *dev, uint16_t pdfid,
690 uint8_t bar_index, uint64_t addr, uint16_t *val);
691int switchtec_ep_bar_read32(
struct switchtec_dev *dev, uint16_t pdfid,
692 uint8_t bar_index, uint64_t addr, uint32_t *val);
693int switchtec_ep_bar_read64(
struct switchtec_dev *dev, uint16_t pdfid,
694 uint8_t bar_index, uint64_t addr, uint64_t *val);
696int switchtec_ep_bar_write8(
struct switchtec_dev *dev, uint16_t pdfid,
697 uint8_t bar_index, uint8_t val, uint64_t addr);
698int switchtec_ep_bar_write16(
struct switchtec_dev *dev, uint16_t pdfid,
699 uint8_t bar_index, uint16_t val, uint64_t addr);
700int switchtec_ep_bar_write32(
struct switchtec_dev *dev, uint16_t pdfid,
701 uint8_t bar_index, uint32_t val, uint64_t addr);
702int switchtec_ep_bar_write64(
struct switchtec_dev *dev, uint16_t pdfid,
703 uint8_t bar_index, uint64_t val, uint64_t addr);
706#define SWITCHTEC_NVME_ADMIN_PASSTHRU_MAX_DATA_LEN (4096 + 16 * 4)
708int switchtec_nvme_admin_passthru(
struct switchtec_dev *dev, uint16_t pdfid,
709 size_t data_len,
void *data,
710 size_t *rsp_len,
void *rsp);
uint8_t clock_sris
Port clock sris, enable/disable.
uint8_t hvd_inst
HVM domain instance index for USP.
uint8_t port_type
Port type.
uint8_t clock_source
CSU channel index for port clock source(0-2)
uint16_t gpio_idx
GPIO index.
Represents each port in the in topology info.
struct gpio_idx_val conn_sig_presence
Presence GPIO pin.
struct gpio_idx_val conn_sig_dsp_perst
DSP PERST# GPIO pin.
uint8_t port_clock_channel
Clock channel.
uint8_t port_connector_id
Connector index.
struct gpio_idx_val conn_sig_8639
SFF-8639 IFDET GPIO pin.
uint8_t port_neg_rate
link rate negotiated
uint8_t phys_port_id
Physical port id.
uint8_t port_minor_ltssm
Minor LTSSM state.
uint8_t port_cfg_width
link width in config file
uint8_t port_cfg_rate
link rate in config file
struct switchtec_fab_port_info::gpio_idx_val conn_sig_pwrctrl
Power controller GPIO pin.
struct gpio_idx_val conn_sig_usp_perst
USP PERST# GPIO pin.
uint8_t port_type
Port type.
uint8_t port_neg_width
link width negotiated
uint8_t port_major_ltssm
Major LTSSM state.
Represents the topology info.
struct switchtec_fab_port_info port_info_list[SWITCHTEC_MAX_PORTS]
Port info list.
uint8_t sw_idx
Switch index.
int num_stack_bif
Number of port bifurcation fields.
uint8_t route_port[16]
Route port.
uint32_t stack_bif[8]
Port bifurcation.
uint64_t port_bitmap
Enabled physical port bitmap.
The event data for SWITCHTEC_GFMS_EVENT_AER.
The event data for SWITCHTEC_GFMS_EVENT_BIND/UNBIND.
The event data for SWITCHTEC_GFMS_EVENT_DEV_ADD/DEL.
The event data for SWITCHTEC_GFMS_EVENT_EP_PORT_ADD/REMOVE.
The event data for SWITCHTEC_GFMS_EVENT_HOST_LINK_UP/DOWN.
The event data for SWITCHTEC_GFMS_EVENT_HVD_INST_ENABLE/DISABLE.
Represents the GFMS event.