16bf9d8f6SLeon Romanovsky /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2a4d61e84SRoland Dreier /*
3a4d61e84SRoland Dreier * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
4a4d61e84SRoland Dreier * Copyright (c) 2004 Infinicon Corporation. All rights reserved.
5a4d61e84SRoland Dreier * Copyright (c) 2004 Intel Corporation. All rights reserved.
6a4d61e84SRoland Dreier * Copyright (c) 2004 Topspin Corporation. All rights reserved.
7a4d61e84SRoland Dreier * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
8a4d61e84SRoland Dreier */
9a4d61e84SRoland Dreier
106bf9d8f6SLeon Romanovsky #ifndef IB_SMI_H
11a4d61e84SRoland Dreier #define IB_SMI_H
12a4d61e84SRoland Dreier
13a4d61e84SRoland Dreier #include <rdma/ib_mad.h>
14a4d61e84SRoland Dreier
15a4d61e84SRoland Dreier #define IB_SMP_DATA_SIZE 64
16a4d61e84SRoland Dreier #define IB_SMP_MAX_PATH_HOPS 64
17a4d61e84SRoland Dreier
18a4d61e84SRoland Dreier struct ib_smp {
19a4d61e84SRoland Dreier u8 base_version;
20a4d61e84SRoland Dreier u8 mgmt_class;
21a4d61e84SRoland Dreier u8 class_version;
22a4d61e84SRoland Dreier u8 method;
23a4d61e84SRoland Dreier __be16 status;
24a4d61e84SRoland Dreier u8 hop_ptr;
25a4d61e84SRoland Dreier u8 hop_cnt;
26a4d61e84SRoland Dreier __be64 tid;
27a4d61e84SRoland Dreier __be16 attr_id;
28a4d61e84SRoland Dreier __be16 resv;
29a4d61e84SRoland Dreier __be32 attr_mod;
30a4d61e84SRoland Dreier __be64 mkey;
31a4d61e84SRoland Dreier __be16 dr_slid;
32a4d61e84SRoland Dreier __be16 dr_dlid;
33a4d61e84SRoland Dreier u8 reserved[28];
34a4d61e84SRoland Dreier u8 data[IB_SMP_DATA_SIZE];
35a4d61e84SRoland Dreier u8 initial_path[IB_SMP_MAX_PATH_HOPS];
36a4d61e84SRoland Dreier u8 return_path[IB_SMP_MAX_PATH_HOPS];
3719b1a294SErez Alfasi } __packed;
38a4d61e84SRoland Dreier
399c3da099SHarvey Harrison #define IB_SMP_DIRECTION cpu_to_be16(0x8000)
40a4d61e84SRoland Dreier
41a4d61e84SRoland Dreier /* Subnet management attributes */
429c3da099SHarvey Harrison #define IB_SMP_ATTR_NOTICE cpu_to_be16(0x0002)
439c3da099SHarvey Harrison #define IB_SMP_ATTR_NODE_DESC cpu_to_be16(0x0010)
449c3da099SHarvey Harrison #define IB_SMP_ATTR_NODE_INFO cpu_to_be16(0x0011)
459c3da099SHarvey Harrison #define IB_SMP_ATTR_SWITCH_INFO cpu_to_be16(0x0012)
469c3da099SHarvey Harrison #define IB_SMP_ATTR_GUID_INFO cpu_to_be16(0x0014)
479c3da099SHarvey Harrison #define IB_SMP_ATTR_PORT_INFO cpu_to_be16(0x0015)
489c3da099SHarvey Harrison #define IB_SMP_ATTR_PKEY_TABLE cpu_to_be16(0x0016)
499c3da099SHarvey Harrison #define IB_SMP_ATTR_SL_TO_VL_TABLE cpu_to_be16(0x0017)
509c3da099SHarvey Harrison #define IB_SMP_ATTR_VL_ARB_TABLE cpu_to_be16(0x0018)
519c3da099SHarvey Harrison #define IB_SMP_ATTR_LINEAR_FORWARD_TABLE cpu_to_be16(0x0019)
529c3da099SHarvey Harrison #define IB_SMP_ATTR_RANDOM_FORWARD_TABLE cpu_to_be16(0x001A)
539c3da099SHarvey Harrison #define IB_SMP_ATTR_MCAST_FORWARD_TABLE cpu_to_be16(0x001B)
549c3da099SHarvey Harrison #define IB_SMP_ATTR_SM_INFO cpu_to_be16(0x0020)
559c3da099SHarvey Harrison #define IB_SMP_ATTR_VENDOR_DIAG cpu_to_be16(0x0030)
569c3da099SHarvey Harrison #define IB_SMP_ATTR_LED_INFO cpu_to_be16(0x0031)
579c3da099SHarvey Harrison #define IB_SMP_ATTR_VENDOR_MASK cpu_to_be16(0xFF00)
58a4d61e84SRoland Dreier
59da2ab62aSLeonid Arsh struct ib_port_info {
60da2ab62aSLeonid Arsh __be64 mkey;
61da2ab62aSLeonid Arsh __be64 gid_prefix;
62da2ab62aSLeonid Arsh __be16 lid;
63da2ab62aSLeonid Arsh __be16 sm_lid;
64da2ab62aSLeonid Arsh __be32 cap_mask;
65da2ab62aSLeonid Arsh __be16 diag_code;
66da2ab62aSLeonid Arsh __be16 mkey_lease_period;
67da2ab62aSLeonid Arsh u8 local_port_num;
68da2ab62aSLeonid Arsh u8 link_width_enabled;
69da2ab62aSLeonid Arsh u8 link_width_supported;
70da2ab62aSLeonid Arsh u8 link_width_active;
71da2ab62aSLeonid Arsh u8 linkspeed_portstate; /* 4 bits, 4 bits */
72da2ab62aSLeonid Arsh u8 portphysstate_linkdown; /* 4 bits, 4 bits */
73da2ab62aSLeonid Arsh u8 mkeyprot_resv_lmc; /* 2 bits, 3, 3 */
74da2ab62aSLeonid Arsh u8 linkspeedactive_enabled; /* 4 bits, 4 bits */
75da2ab62aSLeonid Arsh u8 neighbormtu_mastersmsl; /* 4 bits, 4 bits */
76da2ab62aSLeonid Arsh u8 vlcap_inittype; /* 4 bits, 4 bits */
77da2ab62aSLeonid Arsh u8 vl_high_limit;
78da2ab62aSLeonid Arsh u8 vl_arb_high_cap;
79da2ab62aSLeonid Arsh u8 vl_arb_low_cap;
80da2ab62aSLeonid Arsh u8 inittypereply_mtucap; /* 4 bits, 4 bits */
81da2ab62aSLeonid Arsh u8 vlstallcnt_hoqlife; /* 3 bits, 5 bits */
82da2ab62aSLeonid Arsh u8 operationalvl_pei_peo_fpi_fpo; /* 4 bits, 1, 1, 1, 1 */
83da2ab62aSLeonid Arsh __be16 mkey_violations;
84da2ab62aSLeonid Arsh __be16 pkey_violations;
85da2ab62aSLeonid Arsh __be16 qkey_violations;
86da2ab62aSLeonid Arsh u8 guid_cap;
87da2ab62aSLeonid Arsh u8 clientrereg_resv_subnetto; /* 1 bit, 2 bits, 5 */
88da2ab62aSLeonid Arsh u8 resv_resptimevalue; /* 3 bits, 5 bits */
89da2ab62aSLeonid Arsh u8 localphyerrors_overrunerrors; /* 4 bits, 4 bits */
90da2ab62aSLeonid Arsh __be16 max_credit_hint;
91da2ab62aSLeonid Arsh u8 resv;
92da2ab62aSLeonid Arsh u8 link_roundtrip_latency[3];
93da2ab62aSLeonid Arsh };
94da2ab62aSLeonid Arsh
950629cb06SIra Weiny struct ib_node_info {
960629cb06SIra Weiny u8 base_version;
970629cb06SIra Weiny u8 class_version;
980629cb06SIra Weiny u8 node_type;
990629cb06SIra Weiny u8 num_ports;
1000629cb06SIra Weiny __be64 sys_guid;
1010629cb06SIra Weiny __be64 node_guid;
1020629cb06SIra Weiny __be64 port_guid;
1030629cb06SIra Weiny __be16 partition_cap;
1040629cb06SIra Weiny __be16 device_id;
1050629cb06SIra Weiny __be32 revision;
1060629cb06SIra Weiny u8 local_port_num;
1070629cb06SIra Weiny u8 vendor_id[3];
1080629cb06SIra Weiny } __packed;
1090629cb06SIra Weiny
1100629cb06SIra Weiny struct ib_vl_weight_elem {
1110629cb06SIra Weiny u8 vl; /* IB: VL is low 4 bits, upper 4 bits reserved */
1120629cb06SIra Weiny /* OPA: VL is low 5 bits, upper 3 bits reserved */
1130629cb06SIra Weiny u8 weight;
1140629cb06SIra Weiny };
1150629cb06SIra Weiny
116a4d61e84SRoland Dreier static inline u8
ib_get_smp_direction(struct ib_smp * smp)117a4d61e84SRoland Dreier ib_get_smp_direction(struct ib_smp *smp)
118a4d61e84SRoland Dreier {
119a4d61e84SRoland Dreier return ((smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION);
120a4d61e84SRoland Dreier }
121a4d61e84SRoland Dreier
1220629cb06SIra Weiny /*
1230629cb06SIra Weiny * SM Trap/Notice numbers
1240629cb06SIra Weiny */
1250629cb06SIra Weiny #define IB_NOTICE_TRAP_LLI_THRESH cpu_to_be16(129)
1260629cb06SIra Weiny #define IB_NOTICE_TRAP_EBO_THRESH cpu_to_be16(130)
1270629cb06SIra Weiny #define IB_NOTICE_TRAP_FLOW_UPDATE cpu_to_be16(131)
1280629cb06SIra Weiny #define IB_NOTICE_TRAP_CAP_MASK_CHG cpu_to_be16(144)
1290629cb06SIra Weiny #define IB_NOTICE_TRAP_SYS_GUID_CHG cpu_to_be16(145)
1300629cb06SIra Weiny #define IB_NOTICE_TRAP_BAD_MKEY cpu_to_be16(256)
1310629cb06SIra Weiny #define IB_NOTICE_TRAP_BAD_PKEY cpu_to_be16(257)
1320629cb06SIra Weiny #define IB_NOTICE_TRAP_BAD_QKEY cpu_to_be16(258)
1330629cb06SIra Weiny
1340629cb06SIra Weiny /*
1350629cb06SIra Weiny * Other local changes flags (trap 144).
1360629cb06SIra Weiny */
1370629cb06SIra Weiny #define IB_NOTICE_TRAP_LSE_CHG 0x04 /* Link Speed Enable changed */
1380629cb06SIra Weiny #define IB_NOTICE_TRAP_LWE_CHG 0x02 /* Link Width Enable changed */
1390629cb06SIra Weiny #define IB_NOTICE_TRAP_NODE_DESC_CHG 0x01
1400629cb06SIra Weiny
1410629cb06SIra Weiny /*
1420629cb06SIra Weiny * M_Key volation flags in dr_trunc_hop (trap 256).
1430629cb06SIra Weiny */
1440629cb06SIra Weiny #define IB_NOTICE_TRAP_DR_NOTICE 0x80
1450629cb06SIra Weiny #define IB_NOTICE_TRAP_DR_TRUNC 0x40
1460629cb06SIra Weiny
147*d82e2b27SLeon Romanovsky /**
148*d82e2b27SLeon Romanovsky * ib_init_query_mad - Initialize query MAD.
149*d82e2b27SLeon Romanovsky * @mad: MAD to initialize.
150*d82e2b27SLeon Romanovsky */
ib_init_query_mad(struct ib_smp * mad)151*d82e2b27SLeon Romanovsky static inline void ib_init_query_mad(struct ib_smp *mad)
152*d82e2b27SLeon Romanovsky {
153*d82e2b27SLeon Romanovsky mad->base_version = IB_MGMT_BASE_VERSION;
154*d82e2b27SLeon Romanovsky mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
155*d82e2b27SLeon Romanovsky mad->class_version = 1;
156*d82e2b27SLeon Romanovsky mad->method = IB_MGMT_METHOD_GET;
157*d82e2b27SLeon Romanovsky }
158a4d61e84SRoland Dreier #endif /* IB_SMI_H */
159