18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. 48c2ecf20Sopenharmony_ci * Copyright (c) 2004 Infinicon Corporation. All rights reserved. 58c2ecf20Sopenharmony_ci * Copyright (c) 2004 Intel Corporation. All rights reserved. 68c2ecf20Sopenharmony_ci * Copyright (c) 2004 Topspin Corporation. All rights reserved. 78c2ecf20Sopenharmony_ci * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef IB_SMI_H 118c2ecf20Sopenharmony_ci#define IB_SMI_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <rdma/ib_mad.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define IB_SMP_DATA_SIZE 64 168c2ecf20Sopenharmony_ci#define IB_SMP_MAX_PATH_HOPS 64 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistruct ib_smp { 198c2ecf20Sopenharmony_ci u8 base_version; 208c2ecf20Sopenharmony_ci u8 mgmt_class; 218c2ecf20Sopenharmony_ci u8 class_version; 228c2ecf20Sopenharmony_ci u8 method; 238c2ecf20Sopenharmony_ci __be16 status; 248c2ecf20Sopenharmony_ci u8 hop_ptr; 258c2ecf20Sopenharmony_ci u8 hop_cnt; 268c2ecf20Sopenharmony_ci __be64 tid; 278c2ecf20Sopenharmony_ci __be16 attr_id; 288c2ecf20Sopenharmony_ci __be16 resv; 298c2ecf20Sopenharmony_ci __be32 attr_mod; 308c2ecf20Sopenharmony_ci __be64 mkey; 318c2ecf20Sopenharmony_ci __be16 dr_slid; 328c2ecf20Sopenharmony_ci __be16 dr_dlid; 338c2ecf20Sopenharmony_ci u8 reserved[28]; 348c2ecf20Sopenharmony_ci u8 data[IB_SMP_DATA_SIZE]; 358c2ecf20Sopenharmony_ci u8 initial_path[IB_SMP_MAX_PATH_HOPS]; 368c2ecf20Sopenharmony_ci u8 return_path[IB_SMP_MAX_PATH_HOPS]; 378c2ecf20Sopenharmony_ci} __packed; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define IB_SMP_DIRECTION cpu_to_be16(0x8000) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* Subnet management attributes */ 428c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_NOTICE cpu_to_be16(0x0002) 438c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_NODE_DESC cpu_to_be16(0x0010) 448c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_NODE_INFO cpu_to_be16(0x0011) 458c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_SWITCH_INFO cpu_to_be16(0x0012) 468c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_GUID_INFO cpu_to_be16(0x0014) 478c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_PORT_INFO cpu_to_be16(0x0015) 488c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_PKEY_TABLE cpu_to_be16(0x0016) 498c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_SL_TO_VL_TABLE cpu_to_be16(0x0017) 508c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_VL_ARB_TABLE cpu_to_be16(0x0018) 518c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_LINEAR_FORWARD_TABLE cpu_to_be16(0x0019) 528c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_RANDOM_FORWARD_TABLE cpu_to_be16(0x001A) 538c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_MCAST_FORWARD_TABLE cpu_to_be16(0x001B) 548c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_SM_INFO cpu_to_be16(0x0020) 558c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_VENDOR_DIAG cpu_to_be16(0x0030) 568c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_LED_INFO cpu_to_be16(0x0031) 578c2ecf20Sopenharmony_ci#define IB_SMP_ATTR_VENDOR_MASK cpu_to_be16(0xFF00) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct ib_port_info { 608c2ecf20Sopenharmony_ci __be64 mkey; 618c2ecf20Sopenharmony_ci __be64 gid_prefix; 628c2ecf20Sopenharmony_ci __be16 lid; 638c2ecf20Sopenharmony_ci __be16 sm_lid; 648c2ecf20Sopenharmony_ci __be32 cap_mask; 658c2ecf20Sopenharmony_ci __be16 diag_code; 668c2ecf20Sopenharmony_ci __be16 mkey_lease_period; 678c2ecf20Sopenharmony_ci u8 local_port_num; 688c2ecf20Sopenharmony_ci u8 link_width_enabled; 698c2ecf20Sopenharmony_ci u8 link_width_supported; 708c2ecf20Sopenharmony_ci u8 link_width_active; 718c2ecf20Sopenharmony_ci u8 linkspeed_portstate; /* 4 bits, 4 bits */ 728c2ecf20Sopenharmony_ci u8 portphysstate_linkdown; /* 4 bits, 4 bits */ 738c2ecf20Sopenharmony_ci u8 mkeyprot_resv_lmc; /* 2 bits, 3, 3 */ 748c2ecf20Sopenharmony_ci u8 linkspeedactive_enabled; /* 4 bits, 4 bits */ 758c2ecf20Sopenharmony_ci u8 neighbormtu_mastersmsl; /* 4 bits, 4 bits */ 768c2ecf20Sopenharmony_ci u8 vlcap_inittype; /* 4 bits, 4 bits */ 778c2ecf20Sopenharmony_ci u8 vl_high_limit; 788c2ecf20Sopenharmony_ci u8 vl_arb_high_cap; 798c2ecf20Sopenharmony_ci u8 vl_arb_low_cap; 808c2ecf20Sopenharmony_ci u8 inittypereply_mtucap; /* 4 bits, 4 bits */ 818c2ecf20Sopenharmony_ci u8 vlstallcnt_hoqlife; /* 3 bits, 5 bits */ 828c2ecf20Sopenharmony_ci u8 operationalvl_pei_peo_fpi_fpo; /* 4 bits, 1, 1, 1, 1 */ 838c2ecf20Sopenharmony_ci __be16 mkey_violations; 848c2ecf20Sopenharmony_ci __be16 pkey_violations; 858c2ecf20Sopenharmony_ci __be16 qkey_violations; 868c2ecf20Sopenharmony_ci u8 guid_cap; 878c2ecf20Sopenharmony_ci u8 clientrereg_resv_subnetto; /* 1 bit, 2 bits, 5 */ 888c2ecf20Sopenharmony_ci u8 resv_resptimevalue; /* 3 bits, 5 bits */ 898c2ecf20Sopenharmony_ci u8 localphyerrors_overrunerrors; /* 4 bits, 4 bits */ 908c2ecf20Sopenharmony_ci __be16 max_credit_hint; 918c2ecf20Sopenharmony_ci u8 resv; 928c2ecf20Sopenharmony_ci u8 link_roundtrip_latency[3]; 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistruct ib_node_info { 968c2ecf20Sopenharmony_ci u8 base_version; 978c2ecf20Sopenharmony_ci u8 class_version; 988c2ecf20Sopenharmony_ci u8 node_type; 998c2ecf20Sopenharmony_ci u8 num_ports; 1008c2ecf20Sopenharmony_ci __be64 sys_guid; 1018c2ecf20Sopenharmony_ci __be64 node_guid; 1028c2ecf20Sopenharmony_ci __be64 port_guid; 1038c2ecf20Sopenharmony_ci __be16 partition_cap; 1048c2ecf20Sopenharmony_ci __be16 device_id; 1058c2ecf20Sopenharmony_ci __be32 revision; 1068c2ecf20Sopenharmony_ci u8 local_port_num; 1078c2ecf20Sopenharmony_ci u8 vendor_id[3]; 1088c2ecf20Sopenharmony_ci} __packed; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_cistruct ib_vl_weight_elem { 1118c2ecf20Sopenharmony_ci u8 vl; /* IB: VL is low 4 bits, upper 4 bits reserved */ 1128c2ecf20Sopenharmony_ci /* OPA: VL is low 5 bits, upper 3 bits reserved */ 1138c2ecf20Sopenharmony_ci u8 weight; 1148c2ecf20Sopenharmony_ci}; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_cistatic inline u8 1178c2ecf20Sopenharmony_ciib_get_smp_direction(struct ib_smp *smp) 1188c2ecf20Sopenharmony_ci{ 1198c2ecf20Sopenharmony_ci return ((smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION); 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* 1238c2ecf20Sopenharmony_ci * SM Trap/Notice numbers 1248c2ecf20Sopenharmony_ci */ 1258c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_LLI_THRESH cpu_to_be16(129) 1268c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_EBO_THRESH cpu_to_be16(130) 1278c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_FLOW_UPDATE cpu_to_be16(131) 1288c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_CAP_MASK_CHG cpu_to_be16(144) 1298c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_SYS_GUID_CHG cpu_to_be16(145) 1308c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_BAD_MKEY cpu_to_be16(256) 1318c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_BAD_PKEY cpu_to_be16(257) 1328c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_BAD_QKEY cpu_to_be16(258) 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci/* 1358c2ecf20Sopenharmony_ci * Other local changes flags (trap 144). 1368c2ecf20Sopenharmony_ci */ 1378c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_LSE_CHG 0x04 /* Link Speed Enable changed */ 1388c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_LWE_CHG 0x02 /* Link Width Enable changed */ 1398c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_NODE_DESC_CHG 0x01 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* 1428c2ecf20Sopenharmony_ci * M_Key volation flags in dr_trunc_hop (trap 256). 1438c2ecf20Sopenharmony_ci */ 1448c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_DR_NOTICE 0x80 1458c2ecf20Sopenharmony_ci#define IB_NOTICE_TRAP_DR_TRUNC 0x40 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci#endif /* IB_SMI_H */ 149