1*aa0a1e58SJeff Roberson /* 2*aa0a1e58SJeff Roberson * Copyright (c) 2004 Topspin Communications. All rights reserved. 3*aa0a1e58SJeff Roberson * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 4*aa0a1e58SJeff Roberson * Copyright (c) 2006 Intel Corporation. All rights reserved. 5*aa0a1e58SJeff Roberson * 6*aa0a1e58SJeff Roberson * This software is available to you under a choice of one of two 7*aa0a1e58SJeff Roberson * licenses. You may choose to be licensed under the terms of the GNU 8*aa0a1e58SJeff Roberson * General Public License (GPL) Version 2, available from the file 9*aa0a1e58SJeff Roberson * COPYING in the main directory of this source tree, or the 10*aa0a1e58SJeff Roberson * OpenIB.org BSD license below: 11*aa0a1e58SJeff Roberson * 12*aa0a1e58SJeff Roberson * Redistribution and use in source and binary forms, with or 13*aa0a1e58SJeff Roberson * without modification, are permitted provided that the following 14*aa0a1e58SJeff Roberson * conditions are met: 15*aa0a1e58SJeff Roberson * 16*aa0a1e58SJeff Roberson * - Redistributions of source code must retain the above 17*aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 18*aa0a1e58SJeff Roberson * disclaimer. 19*aa0a1e58SJeff Roberson * 20*aa0a1e58SJeff Roberson * - Redistributions in binary form must reproduce the above 21*aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 22*aa0a1e58SJeff Roberson * disclaimer in the documentation and/or other materials 23*aa0a1e58SJeff Roberson * provided with the distribution. 24*aa0a1e58SJeff Roberson * 25*aa0a1e58SJeff Roberson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26*aa0a1e58SJeff Roberson * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27*aa0a1e58SJeff Roberson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28*aa0a1e58SJeff Roberson * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29*aa0a1e58SJeff Roberson * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30*aa0a1e58SJeff Roberson * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31*aa0a1e58SJeff Roberson * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32*aa0a1e58SJeff Roberson * SOFTWARE. 33*aa0a1e58SJeff Roberson */ 34*aa0a1e58SJeff Roberson 35*aa0a1e58SJeff Roberson #ifndef IB_SA_H 36*aa0a1e58SJeff Roberson #define IB_SA_H 37*aa0a1e58SJeff Roberson 38*aa0a1e58SJeff Roberson #include <linux/completion.h> 39*aa0a1e58SJeff Roberson #include <linux/compiler.h> 40*aa0a1e58SJeff Roberson 41*aa0a1e58SJeff Roberson #include <asm/atomic.h> 42*aa0a1e58SJeff Roberson 43*aa0a1e58SJeff Roberson #include <rdma/ib_verbs.h> 44*aa0a1e58SJeff Roberson #include <rdma/ib_mad.h> 45*aa0a1e58SJeff Roberson 46*aa0a1e58SJeff Roberson enum { 47*aa0a1e58SJeff Roberson IB_SA_CLASS_VERSION = 2, /* IB spec version 1.1/1.2 */ 48*aa0a1e58SJeff Roberson 49*aa0a1e58SJeff Roberson IB_SA_METHOD_GET_TABLE = 0x12, 50*aa0a1e58SJeff Roberson IB_SA_METHOD_GET_TABLE_RESP = 0x92, 51*aa0a1e58SJeff Roberson IB_SA_METHOD_DELETE = 0x15, 52*aa0a1e58SJeff Roberson IB_SA_METHOD_DELETE_RESP = 0x95, 53*aa0a1e58SJeff Roberson IB_SA_METHOD_GET_MULTI = 0x14, 54*aa0a1e58SJeff Roberson IB_SA_METHOD_GET_MULTI_RESP = 0x94, 55*aa0a1e58SJeff Roberson IB_SA_METHOD_GET_TRACE_TBL = 0x13 56*aa0a1e58SJeff Roberson }; 57*aa0a1e58SJeff Roberson 58*aa0a1e58SJeff Roberson enum { 59*aa0a1e58SJeff Roberson IB_SA_ATTR_CLASS_PORTINFO = 0x01, 60*aa0a1e58SJeff Roberson IB_SA_ATTR_NOTICE = 0x02, 61*aa0a1e58SJeff Roberson IB_SA_ATTR_INFORM_INFO = 0x03, 62*aa0a1e58SJeff Roberson IB_SA_ATTR_NODE_REC = 0x11, 63*aa0a1e58SJeff Roberson IB_SA_ATTR_PORT_INFO_REC = 0x12, 64*aa0a1e58SJeff Roberson IB_SA_ATTR_SL2VL_REC = 0x13, 65*aa0a1e58SJeff Roberson IB_SA_ATTR_SWITCH_REC = 0x14, 66*aa0a1e58SJeff Roberson IB_SA_ATTR_LINEAR_FDB_REC = 0x15, 67*aa0a1e58SJeff Roberson IB_SA_ATTR_RANDOM_FDB_REC = 0x16, 68*aa0a1e58SJeff Roberson IB_SA_ATTR_MCAST_FDB_REC = 0x17, 69*aa0a1e58SJeff Roberson IB_SA_ATTR_SM_INFO_REC = 0x18, 70*aa0a1e58SJeff Roberson IB_SA_ATTR_LINK_REC = 0x20, 71*aa0a1e58SJeff Roberson IB_SA_ATTR_GUID_INFO_REC = 0x30, 72*aa0a1e58SJeff Roberson IB_SA_ATTR_SERVICE_REC = 0x31, 73*aa0a1e58SJeff Roberson IB_SA_ATTR_PARTITION_REC = 0x33, 74*aa0a1e58SJeff Roberson IB_SA_ATTR_PATH_REC = 0x35, 75*aa0a1e58SJeff Roberson IB_SA_ATTR_VL_ARB_REC = 0x36, 76*aa0a1e58SJeff Roberson IB_SA_ATTR_MC_MEMBER_REC = 0x38, 77*aa0a1e58SJeff Roberson IB_SA_ATTR_TRACE_REC = 0x39, 78*aa0a1e58SJeff Roberson IB_SA_ATTR_MULTI_PATH_REC = 0x3a, 79*aa0a1e58SJeff Roberson IB_SA_ATTR_SERVICE_ASSOC_REC = 0x3b, 80*aa0a1e58SJeff Roberson IB_SA_ATTR_INFORM_INFO_REC = 0xf3 81*aa0a1e58SJeff Roberson }; 82*aa0a1e58SJeff Roberson 83*aa0a1e58SJeff Roberson enum ib_sa_selector { 84*aa0a1e58SJeff Roberson IB_SA_GT = 0, 85*aa0a1e58SJeff Roberson IB_SA_LT = 1, 86*aa0a1e58SJeff Roberson IB_SA_EQ = 2, 87*aa0a1e58SJeff Roberson /* 88*aa0a1e58SJeff Roberson * The meaning of "best" depends on the attribute: for 89*aa0a1e58SJeff Roberson * example, for MTU best will return the largest available 90*aa0a1e58SJeff Roberson * MTU, while for packet life time, best will return the 91*aa0a1e58SJeff Roberson * smallest available life time. 92*aa0a1e58SJeff Roberson */ 93*aa0a1e58SJeff Roberson IB_SA_BEST = 3 94*aa0a1e58SJeff Roberson }; 95*aa0a1e58SJeff Roberson 96*aa0a1e58SJeff Roberson /* 97*aa0a1e58SJeff Roberson * Structures for SA records are named "struct ib_sa_xxx_rec." No 98*aa0a1e58SJeff Roberson * attempt is made to pack structures to match the physical layout of 99*aa0a1e58SJeff Roberson * SA records in SA MADs; all packing and unpacking is handled by the 100*aa0a1e58SJeff Roberson * SA query code. 101*aa0a1e58SJeff Roberson * 102*aa0a1e58SJeff Roberson * For a record with structure ib_sa_xxx_rec, the naming convention 103*aa0a1e58SJeff Roberson * for the component mask value for field yyy is IB_SA_XXX_REC_YYY (we 104*aa0a1e58SJeff Roberson * never use different abbreviations or otherwise change the spelling 105*aa0a1e58SJeff Roberson * of xxx/yyy between ib_sa_xxx_rec.yyy and IB_SA_XXX_REC_YYY). 106*aa0a1e58SJeff Roberson * 107*aa0a1e58SJeff Roberson * Reserved rows are indicated with comments to help maintainability. 108*aa0a1e58SJeff Roberson */ 109*aa0a1e58SJeff Roberson 110*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_SERVICE_ID (IB_SA_COMP_MASK( 0) |\ 111*aa0a1e58SJeff Roberson IB_SA_COMP_MASK( 1)) 112*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_DGID IB_SA_COMP_MASK( 2) 113*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_SGID IB_SA_COMP_MASK( 3) 114*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_DLID IB_SA_COMP_MASK( 4) 115*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_SLID IB_SA_COMP_MASK( 5) 116*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_RAW_TRAFFIC IB_SA_COMP_MASK( 6) 117*aa0a1e58SJeff Roberson /* reserved: 7 */ 118*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_FLOW_LABEL IB_SA_COMP_MASK( 8) 119*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_HOP_LIMIT IB_SA_COMP_MASK( 9) 120*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_TRAFFIC_CLASS IB_SA_COMP_MASK(10) 121*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_REVERSIBLE IB_SA_COMP_MASK(11) 122*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_NUMB_PATH IB_SA_COMP_MASK(12) 123*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_PKEY IB_SA_COMP_MASK(13) 124*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_QOS_CLASS IB_SA_COMP_MASK(14) 125*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_SL IB_SA_COMP_MASK(15) 126*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_MTU_SELECTOR IB_SA_COMP_MASK(16) 127*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_MTU IB_SA_COMP_MASK(17) 128*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_RATE_SELECTOR IB_SA_COMP_MASK(18) 129*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_RATE IB_SA_COMP_MASK(19) 130*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(20) 131*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(21) 132*aa0a1e58SJeff Roberson #define IB_SA_PATH_REC_PREFERENCE IB_SA_COMP_MASK(22) 133*aa0a1e58SJeff Roberson 134*aa0a1e58SJeff Roberson struct ib_sa_path_rec { 135*aa0a1e58SJeff Roberson __be64 service_id; 136*aa0a1e58SJeff Roberson union ib_gid dgid; 137*aa0a1e58SJeff Roberson union ib_gid sgid; 138*aa0a1e58SJeff Roberson __be16 dlid; 139*aa0a1e58SJeff Roberson __be16 slid; 140*aa0a1e58SJeff Roberson int raw_traffic; 141*aa0a1e58SJeff Roberson /* reserved */ 142*aa0a1e58SJeff Roberson __be32 flow_label; 143*aa0a1e58SJeff Roberson u8 hop_limit; 144*aa0a1e58SJeff Roberson u8 traffic_class; 145*aa0a1e58SJeff Roberson int reversible; 146*aa0a1e58SJeff Roberson u8 numb_path; 147*aa0a1e58SJeff Roberson __be16 pkey; 148*aa0a1e58SJeff Roberson __be16 qos_class; 149*aa0a1e58SJeff Roberson u8 sl; 150*aa0a1e58SJeff Roberson u8 mtu_selector; 151*aa0a1e58SJeff Roberson u8 mtu; 152*aa0a1e58SJeff Roberson u8 rate_selector; 153*aa0a1e58SJeff Roberson u8 rate; 154*aa0a1e58SJeff Roberson u8 packet_life_time_selector; 155*aa0a1e58SJeff Roberson u8 packet_life_time; 156*aa0a1e58SJeff Roberson u8 preference; 157*aa0a1e58SJeff Roberson }; 158*aa0a1e58SJeff Roberson 159*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0) 160*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_PORT_GID IB_SA_COMP_MASK( 1) 161*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_QKEY IB_SA_COMP_MASK( 2) 162*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_MLID IB_SA_COMP_MASK( 3) 163*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_MTU_SELECTOR IB_SA_COMP_MASK( 4) 164*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_MTU IB_SA_COMP_MASK( 5) 165*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS IB_SA_COMP_MASK( 6) 166*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_PKEY IB_SA_COMP_MASK( 7) 167*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_RATE_SELECTOR IB_SA_COMP_MASK( 8) 168*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_RATE IB_SA_COMP_MASK( 9) 169*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(10) 170*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(11) 171*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_SL IB_SA_COMP_MASK(12) 172*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_FLOW_LABEL IB_SA_COMP_MASK(13) 173*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_HOP_LIMIT IB_SA_COMP_MASK(14) 174*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_SCOPE IB_SA_COMP_MASK(15) 175*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_JOIN_STATE IB_SA_COMP_MASK(16) 176*aa0a1e58SJeff Roberson #define IB_SA_MCMEMBER_REC_PROXY_JOIN IB_SA_COMP_MASK(17) 177*aa0a1e58SJeff Roberson 178*aa0a1e58SJeff Roberson struct ib_sa_mcmember_rec { 179*aa0a1e58SJeff Roberson union ib_gid mgid; 180*aa0a1e58SJeff Roberson union ib_gid port_gid; 181*aa0a1e58SJeff Roberson __be32 qkey; 182*aa0a1e58SJeff Roberson __be16 mlid; 183*aa0a1e58SJeff Roberson u8 mtu_selector; 184*aa0a1e58SJeff Roberson u8 mtu; 185*aa0a1e58SJeff Roberson u8 traffic_class; 186*aa0a1e58SJeff Roberson __be16 pkey; 187*aa0a1e58SJeff Roberson u8 rate_selector; 188*aa0a1e58SJeff Roberson u8 rate; 189*aa0a1e58SJeff Roberson u8 packet_life_time_selector; 190*aa0a1e58SJeff Roberson u8 packet_life_time; 191*aa0a1e58SJeff Roberson u8 sl; 192*aa0a1e58SJeff Roberson __be32 flow_label; 193*aa0a1e58SJeff Roberson u8 hop_limit; 194*aa0a1e58SJeff Roberson u8 scope; 195*aa0a1e58SJeff Roberson u8 join_state; 196*aa0a1e58SJeff Roberson int proxy_join; 197*aa0a1e58SJeff Roberson }; 198*aa0a1e58SJeff Roberson 199*aa0a1e58SJeff Roberson /* Service Record Component Mask Sec 15.2.5.14 Ver 1.1 */ 200*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_ID IB_SA_COMP_MASK( 0) 201*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_GID IB_SA_COMP_MASK( 1) 202*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_PKEY IB_SA_COMP_MASK( 2) 203*aa0a1e58SJeff Roberson /* reserved: 3 */ 204*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_LEASE IB_SA_COMP_MASK( 4) 205*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_KEY IB_SA_COMP_MASK( 5) 206*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_NAME IB_SA_COMP_MASK( 6) 207*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_0 IB_SA_COMP_MASK( 7) 208*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_1 IB_SA_COMP_MASK( 8) 209*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_2 IB_SA_COMP_MASK( 9) 210*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_3 IB_SA_COMP_MASK(10) 211*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_4 IB_SA_COMP_MASK(11) 212*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_5 IB_SA_COMP_MASK(12) 213*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_6 IB_SA_COMP_MASK(13) 214*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_7 IB_SA_COMP_MASK(14) 215*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_8 IB_SA_COMP_MASK(15) 216*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_9 IB_SA_COMP_MASK(16) 217*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_10 IB_SA_COMP_MASK(17) 218*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_11 IB_SA_COMP_MASK(18) 219*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_12 IB_SA_COMP_MASK(19) 220*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_13 IB_SA_COMP_MASK(20) 221*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_14 IB_SA_COMP_MASK(21) 222*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA8_15 IB_SA_COMP_MASK(22) 223*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA16_0 IB_SA_COMP_MASK(23) 224*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA16_1 IB_SA_COMP_MASK(24) 225*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA16_2 IB_SA_COMP_MASK(25) 226*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA16_3 IB_SA_COMP_MASK(26) 227*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA16_4 IB_SA_COMP_MASK(27) 228*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA16_5 IB_SA_COMP_MASK(28) 229*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA16_6 IB_SA_COMP_MASK(29) 230*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA16_7 IB_SA_COMP_MASK(30) 231*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA32_0 IB_SA_COMP_MASK(31) 232*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA32_1 IB_SA_COMP_MASK(32) 233*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA32_2 IB_SA_COMP_MASK(33) 234*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA32_3 IB_SA_COMP_MASK(34) 235*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA64_0 IB_SA_COMP_MASK(35) 236*aa0a1e58SJeff Roberson #define IB_SA_SERVICE_REC_SERVICE_DATA64_1 IB_SA_COMP_MASK(36) 237*aa0a1e58SJeff Roberson 238*aa0a1e58SJeff Roberson #define IB_DEFAULT_SERVICE_LEASE 0xFFFFFFFF 239*aa0a1e58SJeff Roberson 240*aa0a1e58SJeff Roberson struct ib_sa_service_rec { 241*aa0a1e58SJeff Roberson u64 id; 242*aa0a1e58SJeff Roberson union ib_gid gid; 243*aa0a1e58SJeff Roberson __be16 pkey; 244*aa0a1e58SJeff Roberson /* reserved */ 245*aa0a1e58SJeff Roberson u32 lease; 246*aa0a1e58SJeff Roberson u8 key[16]; 247*aa0a1e58SJeff Roberson u8 name[64]; 248*aa0a1e58SJeff Roberson u8 data8[16]; 249*aa0a1e58SJeff Roberson u16 data16[8]; 250*aa0a1e58SJeff Roberson u32 data32[4]; 251*aa0a1e58SJeff Roberson u64 data64[2]; 252*aa0a1e58SJeff Roberson }; 253*aa0a1e58SJeff Roberson 254*aa0a1e58SJeff Roberson enum { 255*aa0a1e58SJeff Roberson IB_SA_EVENT_TYPE_FATAL = 0x0, 256*aa0a1e58SJeff Roberson IB_SA_EVENT_TYPE_URGENT = 0x1, 257*aa0a1e58SJeff Roberson IB_SA_EVENT_TYPE_SECURITY = 0x2, 258*aa0a1e58SJeff Roberson IB_SA_EVENT_TYPE_SM = 0x3, 259*aa0a1e58SJeff Roberson IB_SA_EVENT_TYPE_INFO = 0x4, 260*aa0a1e58SJeff Roberson IB_SA_EVENT_TYPE_EMPTY = 0x7F, 261*aa0a1e58SJeff Roberson IB_SA_EVENT_TYPE_ALL = 0xFFFF 262*aa0a1e58SJeff Roberson }; 263*aa0a1e58SJeff Roberson 264*aa0a1e58SJeff Roberson enum { 265*aa0a1e58SJeff Roberson IB_SA_EVENT_PRODUCER_TYPE_CA = 0x1, 266*aa0a1e58SJeff Roberson IB_SA_EVENT_PRODUCER_TYPE_SWITCH = 0x2, 267*aa0a1e58SJeff Roberson IB_SA_EVENT_PRODUCER_TYPE_ROUTER = 0x3, 268*aa0a1e58SJeff Roberson IB_SA_EVENT_PRODUCER_TYPE_CLASS_MANAGER = 0x4, 269*aa0a1e58SJeff Roberson IB_SA_EVENT_PRODUCER_TYPE_ALL = 0xFFFFFF 270*aa0a1e58SJeff Roberson }; 271*aa0a1e58SJeff Roberson 272*aa0a1e58SJeff Roberson enum { 273*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_GID_IN_SERVICE = 64, 274*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_GID_OUT_OF_SERVICE = 65, 275*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_CREATE_MC_GROUP = 66, 276*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_DELETE_MC_GROUP = 67, 277*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_PORT_CHANGE_STATE = 128, 278*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_LINK_INTEGRITY = 129, 279*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_EXCESSIVE_BUFFER_OVERRUN = 130, 280*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_FLOW_CONTROL_UPDATE_EXPIRED = 131, 281*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_BAD_M_KEY = 256, 282*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_BAD_P_KEY = 257, 283*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_BAD_Q_KEY = 258, 284*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_SWITCH_BAD_P_KEY = 259, 285*aa0a1e58SJeff Roberson IB_SA_SM_TRAP_ALL = 0xFFFF 286*aa0a1e58SJeff Roberson }; 287*aa0a1e58SJeff Roberson 288*aa0a1e58SJeff Roberson struct ib_sa_inform { 289*aa0a1e58SJeff Roberson union ib_gid gid; 290*aa0a1e58SJeff Roberson __be16 lid_range_begin; 291*aa0a1e58SJeff Roberson __be16 lid_range_end; 292*aa0a1e58SJeff Roberson u8 is_generic; 293*aa0a1e58SJeff Roberson u8 subscribe; 294*aa0a1e58SJeff Roberson __be16 type; 295*aa0a1e58SJeff Roberson union { 296*aa0a1e58SJeff Roberson struct { 297*aa0a1e58SJeff Roberson __be16 trap_num; 298*aa0a1e58SJeff Roberson __be32 qpn; 299*aa0a1e58SJeff Roberson u8 resp_time; 300*aa0a1e58SJeff Roberson __be32 producer_type; 301*aa0a1e58SJeff Roberson } generic; 302*aa0a1e58SJeff Roberson struct { 303*aa0a1e58SJeff Roberson __be16 device_id; 304*aa0a1e58SJeff Roberson __be32 qpn; 305*aa0a1e58SJeff Roberson u8 resp_time; 306*aa0a1e58SJeff Roberson __be32 vendor_id; 307*aa0a1e58SJeff Roberson } vendor; 308*aa0a1e58SJeff Roberson } trap; 309*aa0a1e58SJeff Roberson }; 310*aa0a1e58SJeff Roberson 311*aa0a1e58SJeff Roberson struct ib_sa_notice { 312*aa0a1e58SJeff Roberson u8 is_generic; 313*aa0a1e58SJeff Roberson u8 type; 314*aa0a1e58SJeff Roberson union { 315*aa0a1e58SJeff Roberson struct { 316*aa0a1e58SJeff Roberson __be32 producer_type; 317*aa0a1e58SJeff Roberson __be16 trap_num; 318*aa0a1e58SJeff Roberson } generic; 319*aa0a1e58SJeff Roberson struct { 320*aa0a1e58SJeff Roberson __be32 vendor_id; 321*aa0a1e58SJeff Roberson __be16 device_id; 322*aa0a1e58SJeff Roberson } vendor; 323*aa0a1e58SJeff Roberson } trap; 324*aa0a1e58SJeff Roberson __be16 issuer_lid; 325*aa0a1e58SJeff Roberson __be16 notice_count; 326*aa0a1e58SJeff Roberson u8 notice_toggle; 327*aa0a1e58SJeff Roberson /* 328*aa0a1e58SJeff Roberson * Align data 16 bits off 64 bit field to match InformInfo definition. 329*aa0a1e58SJeff Roberson * Data contained within this field will then align properly. 330*aa0a1e58SJeff Roberson * See IB spec 1.2, sections 13.4.8.2 and 14.2.5.1. 331*aa0a1e58SJeff Roberson */ 332*aa0a1e58SJeff Roberson u8 reserved[5]; 333*aa0a1e58SJeff Roberson u8 data_details[54]; 334*aa0a1e58SJeff Roberson union ib_gid issuer_gid; 335*aa0a1e58SJeff Roberson }; 336*aa0a1e58SJeff Roberson 337*aa0a1e58SJeff Roberson /* 338*aa0a1e58SJeff Roberson * SM notice data details for: 339*aa0a1e58SJeff Roberson * 340*aa0a1e58SJeff Roberson * IB_SA_SM_TRAP_GID_IN_SERVICE = 64 341*aa0a1e58SJeff Roberson * IB_SA_SM_TRAP_GID_OUT_OF_SERVICE = 65 342*aa0a1e58SJeff Roberson * IB_SA_SM_TRAP_CREATE_MC_GROUP = 66 343*aa0a1e58SJeff Roberson * IB_SA_SM_TRAP_DELETE_MC_GROUP = 67 344*aa0a1e58SJeff Roberson */ 345*aa0a1e58SJeff Roberson struct ib_sa_notice_data_gid { 346*aa0a1e58SJeff Roberson u8 reserved[6]; 347*aa0a1e58SJeff Roberson u8 gid[16]; 348*aa0a1e58SJeff Roberson u8 padding[32]; 349*aa0a1e58SJeff Roberson }; 350*aa0a1e58SJeff Roberson 351*aa0a1e58SJeff Roberson /* 352*aa0a1e58SJeff Roberson * SM notice data details for: 353*aa0a1e58SJeff Roberson * 354*aa0a1e58SJeff Roberson * IB_SA_SM_TRAP_PORT_CHANGE_STATE = 128 355*aa0a1e58SJeff Roberson */ 356*aa0a1e58SJeff Roberson struct ib_sa_notice_data_port_change { 357*aa0a1e58SJeff Roberson __be16 lid; 358*aa0a1e58SJeff Roberson u8 padding[52]; 359*aa0a1e58SJeff Roberson }; 360*aa0a1e58SJeff Roberson 361*aa0a1e58SJeff Roberson /* 362*aa0a1e58SJeff Roberson * SM notice data details for: 363*aa0a1e58SJeff Roberson * 364*aa0a1e58SJeff Roberson * IB_SA_SM_TRAP_LINK_INTEGRITY = 129 365*aa0a1e58SJeff Roberson * IB_SA_SM_TRAP_EXCESSIVE_BUFFER_OVERRUN = 130 366*aa0a1e58SJeff Roberson * IB_SA_SM_TRAP_FLOW_CONTROL_UPDATE_EXPIRED = 131 367*aa0a1e58SJeff Roberson */ 368*aa0a1e58SJeff Roberson struct ib_sa_notice_data_port_error { 369*aa0a1e58SJeff Roberson u8 reserved[2]; 370*aa0a1e58SJeff Roberson __be16 lid; 371*aa0a1e58SJeff Roberson u8 port_num; 372*aa0a1e58SJeff Roberson u8 padding[49]; 373*aa0a1e58SJeff Roberson }; 374*aa0a1e58SJeff Roberson 375*aa0a1e58SJeff Roberson struct ib_sa_client { 376*aa0a1e58SJeff Roberson atomic_t users; 377*aa0a1e58SJeff Roberson struct completion comp; 378*aa0a1e58SJeff Roberson }; 379*aa0a1e58SJeff Roberson 380*aa0a1e58SJeff Roberson /** 381*aa0a1e58SJeff Roberson * ib_sa_register_client - Register an SA client. 382*aa0a1e58SJeff Roberson */ 383*aa0a1e58SJeff Roberson void ib_sa_register_client(struct ib_sa_client *client); 384*aa0a1e58SJeff Roberson 385*aa0a1e58SJeff Roberson /** 386*aa0a1e58SJeff Roberson * ib_sa_unregister_client - Deregister an SA client. 387*aa0a1e58SJeff Roberson * @client: Client object to deregister. 388*aa0a1e58SJeff Roberson */ 389*aa0a1e58SJeff Roberson void ib_sa_unregister_client(struct ib_sa_client *client); 390*aa0a1e58SJeff Roberson 391*aa0a1e58SJeff Roberson struct ib_sa_query; 392*aa0a1e58SJeff Roberson 393*aa0a1e58SJeff Roberson void ib_sa_cancel_query(int id, struct ib_sa_query *query); 394*aa0a1e58SJeff Roberson 395*aa0a1e58SJeff Roberson int ib_sa_path_rec_get(struct ib_sa_client *client, 396*aa0a1e58SJeff Roberson struct ib_device *device, u8 port_num, 397*aa0a1e58SJeff Roberson struct ib_sa_path_rec *rec, 398*aa0a1e58SJeff Roberson ib_sa_comp_mask comp_mask, 399*aa0a1e58SJeff Roberson int timeout_ms, gfp_t gfp_mask, 400*aa0a1e58SJeff Roberson void (*callback)(int status, 401*aa0a1e58SJeff Roberson struct ib_sa_path_rec *resp, 402*aa0a1e58SJeff Roberson void *context), 403*aa0a1e58SJeff Roberson void *context, 404*aa0a1e58SJeff Roberson struct ib_sa_query **query); 405*aa0a1e58SJeff Roberson 406*aa0a1e58SJeff Roberson int ib_sa_service_rec_query(struct ib_sa_client *client, 407*aa0a1e58SJeff Roberson struct ib_device *device, u8 port_num, 408*aa0a1e58SJeff Roberson u8 method, 409*aa0a1e58SJeff Roberson struct ib_sa_service_rec *rec, 410*aa0a1e58SJeff Roberson ib_sa_comp_mask comp_mask, 411*aa0a1e58SJeff Roberson int timeout_ms, gfp_t gfp_mask, 412*aa0a1e58SJeff Roberson void (*callback)(int status, 413*aa0a1e58SJeff Roberson struct ib_sa_service_rec *resp, 414*aa0a1e58SJeff Roberson void *context), 415*aa0a1e58SJeff Roberson void *context, 416*aa0a1e58SJeff Roberson struct ib_sa_query **sa_query); 417*aa0a1e58SJeff Roberson 418*aa0a1e58SJeff Roberson struct ib_sa_multicast { 419*aa0a1e58SJeff Roberson struct ib_sa_mcmember_rec rec; 420*aa0a1e58SJeff Roberson ib_sa_comp_mask comp_mask; 421*aa0a1e58SJeff Roberson int (*callback)(int status, 422*aa0a1e58SJeff Roberson struct ib_sa_multicast *multicast); 423*aa0a1e58SJeff Roberson void *context; 424*aa0a1e58SJeff Roberson }; 425*aa0a1e58SJeff Roberson 426*aa0a1e58SJeff Roberson /** 427*aa0a1e58SJeff Roberson * ib_sa_join_multicast - Initiates a join request to the specified multicast 428*aa0a1e58SJeff Roberson * group. 429*aa0a1e58SJeff Roberson * @client: SA client 430*aa0a1e58SJeff Roberson * @device: Device associated with the multicast group. 431*aa0a1e58SJeff Roberson * @port_num: Port on the specified device to associate with the multicast 432*aa0a1e58SJeff Roberson * group. 433*aa0a1e58SJeff Roberson * @rec: SA multicast member record specifying group attributes. 434*aa0a1e58SJeff Roberson * @comp_mask: Component mask indicating which group attributes of %rec are 435*aa0a1e58SJeff Roberson * valid. 436*aa0a1e58SJeff Roberson * @gfp_mask: GFP mask for memory allocations. 437*aa0a1e58SJeff Roberson * @callback: User callback invoked once the join operation completes. 438*aa0a1e58SJeff Roberson * @context: User specified context stored with the ib_sa_multicast structure. 439*aa0a1e58SJeff Roberson * 440*aa0a1e58SJeff Roberson * This call initiates a multicast join request with the SA for the specified 441*aa0a1e58SJeff Roberson * multicast group. If the join operation is started successfully, it returns 442*aa0a1e58SJeff Roberson * an ib_sa_multicast structure that is used to track the multicast operation. 443*aa0a1e58SJeff Roberson * Users must free this structure by calling ib_free_multicast, even if the 444*aa0a1e58SJeff Roberson * join operation later fails. (The callback status is non-zero.) 445*aa0a1e58SJeff Roberson * 446*aa0a1e58SJeff Roberson * If the join operation fails; status will be non-zero, with the following 447*aa0a1e58SJeff Roberson * failures possible: 448*aa0a1e58SJeff Roberson * -ETIMEDOUT: The request timed out. 449*aa0a1e58SJeff Roberson * -EIO: An error occurred sending the query. 450*aa0a1e58SJeff Roberson * -EINVAL: The MCMemberRecord values differed from the existing group's. 451*aa0a1e58SJeff Roberson * -ENETRESET: Indicates that an fatal error has occurred on the multicast 452*aa0a1e58SJeff Roberson * group, and the user must rejoin the group to continue using it. 453*aa0a1e58SJeff Roberson */ 454*aa0a1e58SJeff Roberson struct ib_sa_multicast *ib_sa_join_multicast(struct ib_sa_client *client, 455*aa0a1e58SJeff Roberson struct ib_device *device, u8 port_num, 456*aa0a1e58SJeff Roberson struct ib_sa_mcmember_rec *rec, 457*aa0a1e58SJeff Roberson ib_sa_comp_mask comp_mask, gfp_t gfp_mask, 458*aa0a1e58SJeff Roberson int (*callback)(int status, 459*aa0a1e58SJeff Roberson struct ib_sa_multicast 460*aa0a1e58SJeff Roberson *multicast), 461*aa0a1e58SJeff Roberson void *context); 462*aa0a1e58SJeff Roberson 463*aa0a1e58SJeff Roberson /** 464*aa0a1e58SJeff Roberson * ib_free_multicast - Frees the multicast tracking structure, and releases 465*aa0a1e58SJeff Roberson * any reference on the multicast group. 466*aa0a1e58SJeff Roberson * @multicast: Multicast tracking structure allocated by ib_join_multicast. 467*aa0a1e58SJeff Roberson * 468*aa0a1e58SJeff Roberson * This call blocks until the multicast identifier is destroyed. It may 469*aa0a1e58SJeff Roberson * not be called from within the multicast callback; however, returning a non- 470*aa0a1e58SJeff Roberson * zero value from the callback will result in destroying the multicast 471*aa0a1e58SJeff Roberson * tracking structure. 472*aa0a1e58SJeff Roberson */ 473*aa0a1e58SJeff Roberson void ib_sa_free_multicast(struct ib_sa_multicast *multicast); 474*aa0a1e58SJeff Roberson 475*aa0a1e58SJeff Roberson /** 476*aa0a1e58SJeff Roberson * ib_get_mcmember_rec - Looks up a multicast member record by its MGID and 477*aa0a1e58SJeff Roberson * returns it if found. 478*aa0a1e58SJeff Roberson * @device: Device associated with the multicast group. 479*aa0a1e58SJeff Roberson * @port_num: Port on the specified device to associate with the multicast 480*aa0a1e58SJeff Roberson * group. 481*aa0a1e58SJeff Roberson * @mgid: MGID of multicast group. 482*aa0a1e58SJeff Roberson * @rec: Location to copy SA multicast member record. 483*aa0a1e58SJeff Roberson */ 484*aa0a1e58SJeff Roberson int ib_sa_get_mcmember_rec(struct ib_device *device, u8 port_num, 485*aa0a1e58SJeff Roberson union ib_gid *mgid, struct ib_sa_mcmember_rec *rec); 486*aa0a1e58SJeff Roberson 487*aa0a1e58SJeff Roberson /** 488*aa0a1e58SJeff Roberson * ib_init_ah_from_mcmember - Initialize address handle attributes based on 489*aa0a1e58SJeff Roberson * an SA multicast member record. 490*aa0a1e58SJeff Roberson */ 491*aa0a1e58SJeff Roberson int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num, 492*aa0a1e58SJeff Roberson struct ib_sa_mcmember_rec *rec, 493*aa0a1e58SJeff Roberson struct ib_ah_attr *ah_attr); 494*aa0a1e58SJeff Roberson 495*aa0a1e58SJeff Roberson /** 496*aa0a1e58SJeff Roberson * ib_init_ah_from_path - Initialize address handle attributes based on an SA 497*aa0a1e58SJeff Roberson * path record. 498*aa0a1e58SJeff Roberson */ 499*aa0a1e58SJeff Roberson int ib_init_ah_from_path(struct ib_device *device, u8 port_num, 500*aa0a1e58SJeff Roberson struct ib_sa_path_rec *rec, 501*aa0a1e58SJeff Roberson struct ib_ah_attr *ah_attr); 502*aa0a1e58SJeff Roberson 503*aa0a1e58SJeff Roberson /** 504*aa0a1e58SJeff Roberson * ib_sa_unpack_path - Convert a path record from MAD format to struct 505*aa0a1e58SJeff Roberson * ib_sa_path_rec. 506*aa0a1e58SJeff Roberson */ 507*aa0a1e58SJeff Roberson void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec); 508*aa0a1e58SJeff Roberson 509*aa0a1e58SJeff Roberson struct ib_inform_info { 510*aa0a1e58SJeff Roberson void *context; 511*aa0a1e58SJeff Roberson int (*callback)(int status, 512*aa0a1e58SJeff Roberson struct ib_inform_info *info, 513*aa0a1e58SJeff Roberson struct ib_sa_notice *notice); 514*aa0a1e58SJeff Roberson u16 trap_number; 515*aa0a1e58SJeff Roberson }; 516*aa0a1e58SJeff Roberson 517*aa0a1e58SJeff Roberson /** 518*aa0a1e58SJeff Roberson * ib_sa_register_inform_info - Registers to receive notice events. 519*aa0a1e58SJeff Roberson * @device: Device associated with the registration. 520*aa0a1e58SJeff Roberson * @port_num: Port on the specified device to associate with the registration. 521*aa0a1e58SJeff Roberson * @trap_number: InformInfo trap number to register for. 522*aa0a1e58SJeff Roberson * @gfp_mask: GFP mask for memory allocations. 523*aa0a1e58SJeff Roberson * @callback: User callback invoked once the registration completes and to 524*aa0a1e58SJeff Roberson * report noticed events. 525*aa0a1e58SJeff Roberson * @context: User specified context stored with the ib_inform_reg structure. 526*aa0a1e58SJeff Roberson * 527*aa0a1e58SJeff Roberson * This call initiates a registration request with the SA for the specified 528*aa0a1e58SJeff Roberson * trap number. If the operation is started successfully, it returns 529*aa0a1e58SJeff Roberson * an ib_inform_info structure that is used to track the registration operation. 530*aa0a1e58SJeff Roberson * Users must free this structure by calling ib_unregister_inform_info, 531*aa0a1e58SJeff Roberson * even if the operation later fails. (The callback status is non-zero.) 532*aa0a1e58SJeff Roberson * 533*aa0a1e58SJeff Roberson * If the registration fails; status will be non-zero. If the registration 534*aa0a1e58SJeff Roberson * succeeds, the callback status will be zero, but the notice parameter will 535*aa0a1e58SJeff Roberson * be NULL. If the notice parameter is not NULL, a trap or notice is being 536*aa0a1e58SJeff Roberson * reported to the user. 537*aa0a1e58SJeff Roberson * 538*aa0a1e58SJeff Roberson * A status of -ENETRESET indicates that an error occurred which requires 539*aa0a1e58SJeff Roberson * reregisteration. 540*aa0a1e58SJeff Roberson */ 541*aa0a1e58SJeff Roberson struct ib_inform_info * 542*aa0a1e58SJeff Roberson ib_sa_register_inform_info(struct ib_sa_client *client, 543*aa0a1e58SJeff Roberson struct ib_device *device, u8 port_num, 544*aa0a1e58SJeff Roberson u16 trap_number, gfp_t gfp_mask, 545*aa0a1e58SJeff Roberson int (*callback)(int status, 546*aa0a1e58SJeff Roberson struct ib_inform_info *info, 547*aa0a1e58SJeff Roberson struct ib_sa_notice *notice), 548*aa0a1e58SJeff Roberson void *context); 549*aa0a1e58SJeff Roberson 550*aa0a1e58SJeff Roberson /** 551*aa0a1e58SJeff Roberson * ib_sa_unregister_inform_info - Releases an InformInfo registration. 552*aa0a1e58SJeff Roberson * @info: InformInfo registration tracking structure. 553*aa0a1e58SJeff Roberson * 554*aa0a1e58SJeff Roberson * This call blocks until the registration request is destroyed. It may 555*aa0a1e58SJeff Roberson * not be called from within the registration callback. 556*aa0a1e58SJeff Roberson */ 557*aa0a1e58SJeff Roberson void ib_sa_unregister_inform_info(struct ib_inform_info *info); 558*aa0a1e58SJeff Roberson 559*aa0a1e58SJeff Roberson #endif /* IB_SA_H */ 560