1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_IB_IBTL_IBTI_COMMON_H 27 #define _SYS_IB_IBTL_IBTI_COMMON_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 /* 32 * ibti_common.h 33 * 34 * This file contains the shared/common transport data types and function 35 * prototypes. 36 */ 37 #include <sys/ib/ibtl/ibtl_types.h> 38 #include <sys/ib/ibtl/ibti_cm.h> 39 #include <sys/isa_defs.h> 40 #include <sys/byteorder.h> 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /* 47 * Endian Macros 48 * h2b - host endian to big endian protocol 49 * b2h - big endian protocol to host endian 50 * h2l - host endian to little endian protocol 51 * l2h - little endian protocol to host endian 52 */ 53 #if defined(_LITTLE_ENDIAN) 54 #define h2b16(x) (htons(x)) 55 #define h2b32(x) (htonl(x)) 56 #define h2b64(x) (ddi_swap64(x)) 57 #define b2h16(x) (ntohs(x)) 58 #define b2h32(x) (ntohl(x)) 59 #define b2h64(x) (ddi_swap64(x)) 60 61 #define h2l16(x) (x) 62 #define h2l32(x) (x) 63 #define h2l64(x) (x) 64 #define l2h16(x) (x) 65 #define l2h32(x) (x) 66 #define l2h64(x) (x) 67 68 #elif defined(_BIG_ENDIAN) 69 #define h2b16(x) (x) 70 #define h2b32(x) (x) 71 #define h2b64(x) (x) 72 #define b2h16(x) (x) 73 #define b2h32(x) (x) 74 #define b2h64(x) (x) 75 76 #define h2l16(x) (ddi_swap16(x)) 77 #define h2l32(x) (ddi_swap32(x)) 78 #define h2l64(x) (ddi_swap64(x)) 79 #define l2h16(x) (ddi_swap16(x)) 80 #define l2h32(x) (ddi_swap32(x)) 81 #define l2h64(x) (ddi_swap64(x)) 82 83 #else 84 #error "what endian is this machine?" 85 #endif 86 87 /* 88 * Max number of paths that can be requested in an ibt_get_paths() call, 89 * if IBT_PATH_PERF or IBT_PATH_AVAIL flag (ibt_path_flags_t) is set. 90 */ 91 #define IBT_MAX_SPECIAL_PATHS 2 92 93 /* 94 * The name of DDI Event, generated when the properties of IOC device 95 * node properties were modified. 96 */ 97 #define IB_PROP_UPDATE_EVENT "SUNW,IB:IB_PROP_UPDATE" 98 99 100 /* Transport Interface version */ 101 typedef enum ibt_version_e { 102 IBTI_V1 = 1, 103 IBTI_V2 = 2 /* FMR Support */ 104 } ibt_version_t; 105 106 /* 107 * Driver class type. Identifies a type of client driver so that 108 * "IBTF Policy" decisions can be made on a driver class basis. 109 * The last class should always be IBT_CLNT_NUM, and any new classes added 110 * must be defined before IBT_CLNT_NUM. The class values must be above 0. 111 * Any class values below or equal to 0 shall be invalid 112 */ 113 typedef enum ibt_clnt_class_e { 114 IBT_STORAGE_DEV = 0x1, /* SCSI, FC, etc.. */ 115 IBT_NETWORK_DEV, /* Network driver with associated client H/W */ 116 IBT_GENERIC_DEV, /* Generic client H/W device driver */ 117 IBT_NETWORK, /* Network driver with no associated */ 118 /* client H/W, e.g., IPoIB */ 119 IBT_GENERIC, /* A generic IB driver not */ 120 /* associated with client H/W */ 121 IBT_USER, /* A user application IBT interface driver */ 122 IBT_IBMA, /* The IBMA Module */ 123 IBT_CM, /* The CM Module */ 124 IBT_DM, /* The DM Module */ 125 IBT_CLASS_NUM /* Place holder for class count */ 126 } ibt_clnt_class_t; 127 128 #define IBT_TEST_DEV 999 /* Place holder for modules that test IBTL */ 129 130 #define IBT_CLNT_DEVICE_CLASS(class) ((class) == IBT_STORAGE_DEV || \ 131 (class) == IBT_NETWORK_DEV || \ 132 (class) == IBT_GENERIC_DEV) 133 134 #define IBT_CLNT_GENERAL_CLASS(class) ((class) == IBT_NETWORK || \ 135 (class) == IBT_GENERIC || \ 136 (class) == IBT_USER) 137 138 #define IBT_CLNT_MGMT_CLASS(class) ((class) == IBT_IBMA || \ 139 (class) == IBT_CM || \ 140 (class) == IBT_DM || \ 141 (class) == IBT_TEST_DEV) 142 /* 143 * Event record & status returns for asynchronous events and errors. 144 */ 145 typedef struct ibt_async_event_s { 146 uint64_t ev_fma_ena; /* FMA Error data */ 147 ibt_channel_hdl_t ev_chan_hdl; /* Channel handle */ 148 ibt_cq_hdl_t ev_cq_hdl; /* CQ handle */ 149 ib_guid_t ev_hca_guid; /* HCA node GUID */ 150 uint8_t ev_port; /* HCA port */ 151 ibt_srq_hdl_t ev_srq_hdl; /* SRQ handle */ 152 } ibt_async_event_t; 153 154 /* 155 * IBT Client Callback function typedefs. 156 * 157 * ibt_async_handler_t 158 * Pointer to an async event/error handler function. This function is 159 * called when an async event/error is detected on a HCA that is being 160 * used by the IBT client driver that registered the function. 161 */ 162 typedef void (*ibt_async_handler_t)(void *clnt_private, 163 ibt_hca_hdl_t hca_hdl, ibt_async_code_t code, ibt_async_event_t *event); 164 165 /* 166 * IBT Client Memory Error Callback function typedefs. 167 * 168 * ibt_memory_handler_t 169 * Pointer to an memory event/error handler function. 170 */ 171 typedef void (*ibt_memory_handler_t)(void *clnt_private, 172 ibt_hca_hdl_t hca_hdl, ibt_mem_code_t code, ibt_mem_data_t *data); 173 174 /* 175 * Define a client module information structure. All clients MUST 176 * define a global of type ibt_clnt_modinfo_t. A pointer to this global 177 * is passed into the IBTF by a client when calling ibt_attach(). 178 * This struct must persist during the life of the client. 179 * 180 * The client's mi_async_handler is called when an async event/error is 181 * detected on a HCA that is being used by this client. 182 */ 183 typedef struct ibt_clnt_modinfo_s { 184 ibt_version_t mi_ibt_version; /* TI version */ 185 ibt_clnt_class_t mi_clnt_class; /* Type of client */ 186 ibt_async_handler_t mi_async_handler; /* Async Handler */ 187 ibt_memory_handler_t mi_reserved; /* Memory handler */ 188 char *mi_clnt_name; /* Client Name. */ 189 } ibt_clnt_modinfo_t; 190 191 192 /* 193 * Definitions for use with ibt_register_subnet_notices() 194 */ 195 typedef enum ibt_subnet_event_code_e { 196 IBT_SM_EVENT_MCG_CREATED = 1, 197 IBT_SM_EVENT_MCG_DELETED = 2, 198 IBT_SM_EVENT_AVAILABLE = 3, 199 IBT_SM_EVENT_UNAVAILABLE = 4, 200 IBT_SM_EVENT_GID_AVAIL = 5, 201 IBT_SM_EVENT_GID_UNAVAIL = 6 202 } ibt_subnet_event_code_t; 203 204 typedef struct ibt_subnet_event_s { 205 ib_gid_t sm_notice_gid; 206 } ibt_subnet_event_t; 207 208 typedef void (*ibt_sm_notice_handler_t)(void *private, ib_gid_t gid, 209 ibt_subnet_event_code_t code, ibt_subnet_event_t *event); 210 211 212 /* 213 * MTU Request type. 214 */ 215 typedef struct ibt_mtu_req_s { 216 ib_mtu_t r_mtu; /* Requested MTU */ 217 ibt_selector_t r_selector; /* Qualifier for r_mtu */ 218 } ibt_mtu_req_t; 219 220 221 /* 222 * Qflags, used by ibt_resize_queues(). 223 */ 224 typedef enum ibt_qflags_e { 225 IBT_SEND_Q = 1 << 0, /* Op applies to the Send Q */ 226 IBT_RECV_Q = 1 << 1 /* Op applies to the Recv Q */ 227 } ibt_qflags_t; 228 229 /* 230 * CQ priorities 231 * The IBTF will attempt to implement a coarse 3 level priority scheme 232 * (IBT_CQ_LOW, IBT_CQ_MEDIUM, IBT_CQ_HIGH) based on the class of client 233 * driver. The requested priority is not guaranteed. If a CI implementation 234 * has the ability to implement priority CQs, then the IBTF will take advantage 235 * of that when calling the CI to create a CQ by passing a priority indicator 236 * to the CI. 237 */ 238 typedef enum ibt_cq_priority_e { 239 IBT_CQ_DEFAULT = 0x0, 240 IBT_CQ_LOW = 0x1, 241 IBT_CQ_MEDIUM = 0x2, 242 IBT_CQ_HIGH = 0x3, 243 IBT_CQ_OPAQUE_1 = 0x4, 244 IBT_CQ_OPAQUE_2 = 0x5, 245 IBT_CQ_OPAQUE_3 = 0x6, 246 IBT_CQ_OPAQUE_4 = 0x7, 247 IBT_CQ_OPAQUE_5 = 0x8, 248 IBT_CQ_OPAQUE_6 = 0x9, 249 IBT_CQ_OPAQUE_7 = 0xA, 250 IBT_CQ_OPAQUE_8 = 0xB, 251 IBT_CQ_OPAQUE_9 = 0xC, 252 IBT_CQ_OPAQUE_10 = 0xD, 253 IBT_CQ_OPAQUE_11 = 0xE, 254 IBT_CQ_OPAQUE_12 = 0xF, 255 IBT_CQ_OPAQUE_13 = 0x10, 256 IBT_CQ_OPAQUE_14 = 0x11, 257 IBT_CQ_OPAQUE_15 = 0x12, 258 IBT_CQ_OPAQUE_16 = 0x13 259 } ibt_cq_priority_t; 260 261 /* 262 * Attributes when creating a Completion Queue Scheduling Handle. 263 */ 264 typedef struct ibt_cq_sched_attr_s { 265 ibt_cq_sched_flags_t cqs_flags; 266 ibt_cq_priority_t cqs_priority; 267 uint_t cqs_load; 268 ibt_sched_hdl_t cqs_affinity_hdl; 269 } ibt_cq_sched_attr_t; 270 271 272 /* 273 * ibt_cq_handler_t 274 * Pointer to a work request completion handler function. This function 275 * is called when a WR completes on a CQ that is being used by the IBTF 276 * client driver that registered the function. 277 */ 278 typedef void (*ibt_cq_handler_t)(ibt_cq_hdl_t ibt_cq, void *arg); 279 280 /* 281 * Service Data and flags. 282 * (IBTA Spec Release 1.1, Vol-1 Ref: 15.2.5.14.4) 283 * 284 * The ServiceData8.1 (sb_data8[0]) through ServiceData64.2 (sb_data64[1]) 285 * components together constitutes a 64-byte area in which any data may be 286 * placed. It is intended to be a convenient way for a service to provide its 287 * clients with some initial data. 288 * 289 * In addition, this 64-byte area is formally divided into a total of 30 290 * components, 16 8-bit (uint8_t) components, then 8 16-bit (uint16_t) 291 * components, then 6 32-bit (uint32_t) components, then 2 64-bit (uint64_t) 292 * components, thereby assigning ComponentMask bits (ibt_srv_data_flags_t) to 293 * variously-sized segments of the data. All data are in host endian format. 294 * This allows query operations (ibt_get_paths()) to be used which match 295 * parts of the Service Data, making it possible, for example, for 296 * service-specific parts of the ServiceData to serve as a binary-coded 297 * extension to the ServiceName for purposes of lookup. 298 */ 299 typedef enum ibt_srv_data_flags_e { 300 IBT_NO_SDATA = 0, 301 302 IBT_SDATA8_0 = (1 << 0), 303 IBT_SDATA8_1 = (1 << 1), 304 IBT_SDATA8_2 = (1 << 2), 305 IBT_SDATA8_3 = (1 << 3), 306 IBT_SDATA8_4 = (1 << 4), 307 IBT_SDATA8_5 = (1 << 5), 308 IBT_SDATA8_6 = (1 << 6), 309 IBT_SDATA8_7 = (1 << 7), 310 IBT_SDATA8_8 = (1 << 8), 311 IBT_SDATA8_9 = (1 << 9), 312 IBT_SDATA8_10 = (1 << 10), 313 IBT_SDATA8_11 = (1 << 11), 314 IBT_SDATA8_12 = (1 << 12), 315 IBT_SDATA8_13 = (1 << 13), 316 IBT_SDATA8_14 = (1 << 14), 317 IBT_SDATA8_15 = (1 << 15), 318 319 IBT_SDATA16_0 = (1 << 16), 320 IBT_SDATA16_1 = (1 << 17), 321 IBT_SDATA16_2 = (1 << 18), 322 IBT_SDATA16_3 = (1 << 19), 323 IBT_SDATA16_4 = (1 << 20), 324 IBT_SDATA16_5 = (1 << 21), 325 IBT_SDATA16_6 = (1 << 22), 326 IBT_SDATA16_7 = (1 << 23), 327 328 IBT_SDATA32_0 = (1 << 24), 329 IBT_SDATA32_1 = (1 << 25), 330 IBT_SDATA32_2 = (1 << 26), 331 IBT_SDATA32_3 = (1 << 27), 332 333 IBT_SDATA64_0 = (1 << 28), 334 IBT_SDATA64_1 = (1 << 29), 335 336 IBT_SDATA_ALL = 0x3FFFFFFF 337 } ibt_srv_data_flags_t; 338 339 typedef struct ibt_srv_data_s { 340 uint8_t s_data8[16]; /* 8-bit service data fields. */ 341 uint16_t s_data16[8]; /* 16-bit service data fields. */ 342 uint32_t s_data32[4]; /* 32-bit service data fields. */ 343 uint64_t s_data64[2]; /* 64-bit service data fields. */ 344 } ibt_srv_data_t; 345 346 /* 347 * Path flags, used in ibt_get_paths() 348 */ 349 typedef enum ibt_path_flags_e { 350 IBT_PATH_NO_FLAGS = 0, 351 IBT_PATH_APM = 1 << 0, /* APM is desired. */ 352 IBT_PATH_AVAIL = 1 << 2, 353 IBT_PATH_PERF = 1 << 3, 354 IBT_PATH_MULTI_SVC_DEST = 1 << 4, /* Multiple ServiceRecords */ 355 IBT_PATH_HOP = 1 << 5, /* pa_hop is specified. */ 356 IBT_PATH_PKEY = 1 << 6 /* pa_pkey is specified. */ 357 } ibt_path_flags_t; 358 359 /* 360 * Path attributes. 361 * 362 * The ibt_path_attr_t structure is used to specify required attributes in a 363 * path from the requesting (source) node to a specified destination node. 364 * Attributes that are don't care should be set to NULL or '0'. 365 * A destination must be specified, where a destination can be defined as 366 * one of the following: 367 * 368 * o Service Name 369 * o Service ID (SID) 370 * o Array of DGIDs. 371 * o Service Name and Array of DGIDs. 372 */ 373 typedef struct ibt_path_attr_s { 374 ib_gid_t *pa_dgids; /* Array of DGIDs */ 375 ib_gid_t pa_sgid; 376 ib_guid_t pa_hca_guid; 377 char *pa_sname; /* ASCII Service name */ 378 /* NULL Terminated */ 379 ib_svc_id_t pa_sid; /* Service ID */ 380 ibt_srv_data_flags_t pa_sd_flags; /* Service Data flags. */ 381 ibt_srv_data_t pa_sdata; /* Service Data */ 382 uint8_t pa_hca_port_num; 383 uint8_t pa_num_dgids; /* size of pa_dgids array */ 384 uint8_t pa_sl:4; 385 ibt_mtu_req_t pa_mtu; 386 ibt_srate_req_t pa_srate; 387 ibt_pkt_lt_req_t pa_pkt_lt; /* Packet Life Time Request */ 388 uint_t pa_flow:20; 389 uint8_t pa_hop; /* IBT_PATH_HOP */ 390 uint8_t pa_tclass; 391 ib_pkey_t pa_pkey; /* IBT_PATH_PKEY */ 392 } ibt_path_attr_t; 393 394 /* 395 * Path Information. 396 * 397 * The ibt_get_paths() performs SA Path record lookups to select a path(s) to 398 * a given destination(s), details of selected path(s) are returned in this 399 * structure. 400 * 401 * The ibt_path_info_t contains all the attributes of the best path(s), as 402 * as determined by IBTL, to the specified destination(s), including the 403 * local HCA and HCA port to use to access the fabric. 404 * 405 * The Service ID (pi_sid) and Service Data (pi_sdata) are returned only for 406 * lookups based on Service ID or/and Service Name. 407 */ 408 typedef struct ibt_path_info_s { 409 ib_guid_t pi_hca_guid; /* Local HCA GUID; 0 implies */ 410 /* this record is invalid */ 411 ib_svc_id_t pi_sid; /* Service ID */ 412 ibt_srv_data_t pi_sdata; /* Service Data */ 413 414 ibt_cep_path_t pi_prim_cep_path; /* Contains CEP adds info */ 415 ibt_cep_path_t pi_alt_cep_path; /* RC & UC Only, valid if */ 416 /* cep_hca_port_num is not */ 417 /* '0' */ 418 ib_mtu_t pi_path_mtu; /* Common path MTU */ 419 ib_time_t pi_prim_pkt_lt; 420 ib_time_t pi_alt_pkt_lt; 421 } ibt_path_info_t; 422 423 /* 424 * Optional Alternate Path attributes. 425 * 426 * The ibt_alt_path_attr_t structure is used to specify additional optional 427 * attributes when requesting an alternate path for an existing channel. 428 * 429 * Attributes that are don't care should be set to NULL or '0'. 430 */ 431 typedef struct ibt_alt_path_attr_s { 432 ib_gid_t apa_sgid; 433 ib_gid_t apa_dgid; 434 ibt_srate_req_t apa_srate; 435 ibt_pkt_lt_req_t apa_pkt_lt; /* Packet Life Time Request */ 436 uint_t apa_flow:20; 437 uint8_t apa_sl:4; 438 uint8_t apa_hop; 439 uint8_t apa_tclass; 440 } ibt_alt_path_attr_t; 441 442 /* 443 * Path Information for Alternate Path - input to ibt_set_alt_path(). 444 */ 445 typedef struct ibt_alt_path_info_s { 446 ibt_cep_path_t ap_alt_cep_path; /* RC & UC Only, valid if */ 447 /* cep_hca_port_num is not */ 448 /* '0' */ 449 ib_time_t ap_alt_pkt_lt; 450 } ibt_alt_path_info_t; 451 452 /* 453 * Open Channel flags, Used in ibt_open_rc_channel call 454 */ 455 typedef enum ibt_chan_open_flags_e { 456 IBT_OCHAN_NO_FLAGS = 0, 457 IBT_OCHAN_REDIRECTED = 1 << 0, 458 IBT_OCHAN_PORT_REDIRECTED = 1 << 1, 459 IBT_OCHAN_DUP = 1 << 2, 460 IBT_OCHAN_PORT_FIXED = 1 << 3, 461 IBT_OCHAN_OPAQUE1 = 1 << 4, 462 IBT_OCHAN_OPAQUE2 = 1 << 5, 463 IBT_OCHAN_OPAQUE3 = 1 << 6, 464 IBT_OCHAN_OPAQUE4 = 1 << 7, 465 IBT_OCHAN_OPAQUE5 = 1 << 8 466 } ibt_chan_open_flags_t; 467 468 /* 469 * Arguments for ibt_open_rc_channel(). 470 * 471 * oc_priv_data should be NULL or point to a buffer allocated by the caller, 472 * the size of which should be in oc_priv_data_len, where oc_priv_data_len <= 473 * IBT_REQ_PRIV_DATA_SZ. 474 * 475 * When ibt_open_rc_channel returns with ibt_cm_reason_t of 476 * IBT_CM_REDIRECT_PORT, the client can re-issue ibt_open_rc_channel setting 477 * new fields as follows: 478 * 479 * Set (ibt_chan_args_t)->oc_cm_cep_path = 480 * original (ibt_chan_open_args_t)->oc_path->pi_prim_cep_path. 481 * Set (ibt_chan_args_t)->oc_cm_pkt_lt = 482 * original (ibt_chan_open_args_t)->oc_prim_pkt_lt. 483 * Update (ibt_chan_args_t)->oc_path based on path information returned 484 * from ibt_get_paths using the gid in the return data below: 485 * (ibt_rc_returns_t)->rc_arej_info.ari_redirect_info.ari_gid. 486 * Set flags to IBT_OCHAN_PORT_REDIRECTED. 487 * 488 * Note : oc_cm_path is not used for any other scenario, and must be set for 489 * IBT_OCHAN_PORT_REDIRECTED. 490 * 491 * When ibt_open_rc_channel returns with ibt_cm_reason_t of 492 * IBT_CM_REDIRECT_CM, the client can re-issue ibt_open_rc_channel setting 493 * new fields as follows: 494 * 495 * Update (ibt_chan_args_t)->oc_path based on path information returned 496 * from ibt_get_paths using the return data in 497 * (ibt_rc_returns_t)->rc_arej_info.ari_redirect_info. 498 * 499 * Set (ibt_chan_args_t)->oc_cm_redirect_info = 500 * Returned (ibt_rc_returns_t)->rc_arej_info.ari_redirect_info. 501 * Set flags to IBT_OCHAN_REDIRECTED. 502 * 503 * Note: 504 * 505 * IBT_OCHAN_PORT_REDIRECTED flag cannot be used to specify a remote CM MAD 506 * address, that is on a different subnet than the RC connection itself. 507 * 508 * Not specified attributes should be set to "NULL" or "0". 509 */ 510 typedef struct ibt_chan_open_args_s { 511 ibt_path_info_t *oc_path; /* Primary & Alternate */ 512 ibt_cm_handler_t oc_cm_handler; /* cm_handler - required */ 513 void *oc_cm_clnt_private; /* First argument to */ 514 /* cm_handler */ 515 ibt_rnr_retry_cnt_t oc_path_rnr_retry_cnt; 516 uint8_t oc_path_retry_cnt:3; 517 uint8_t oc_rdma_ra_out; 518 uint8_t oc_rdma_ra_in; 519 ibt_priv_data_len_t oc_priv_data_len; /* Number of bytes of */ 520 /* REQ Private data */ 521 void *oc_priv_data; /* REQ private data */ 522 ibt_channel_hdl_t oc_dup_channel; /* IBT_OCHAN_DUP */ 523 ibt_redirect_info_t *oc_cm_redirect_info; /* Redirect params */ 524 /* for port and CM */ 525 /* redirection */ 526 ibt_cep_path_t *oc_cm_cep_path; /* Optional Path for */ 527 /* CM MADs on */ 528 /* port redirection */ 529 ib_time_t oc_cm_pkt_lt; /* Pkt life time for */ 530 /* CM MADs */ 531 uint32_t oc_opaque1:4; 532 uint32_t oc_opaque2:24; 533 uint32_t oc_opaque3; 534 uint32_t oc_opaque4; 535 } ibt_chan_open_args_t; 536 537 538 /* 539 * Define an optional RC return arguments structure. This contains return 540 * parameters from ibt_open_rc_channel() when called in BLOCKING mode. 541 * 542 * rc_priv_data should be NULL or point to a buffer allocated by the caller, 543 * the size of which should be in rc_priv_data_len, where rc_priv_data_len <= 544 * IBT_REP_PRIV_DATA_SZ. 545 */ 546 typedef struct ibt_rc_returns_s { 547 uint8_t rc_rdma_ra_in; /* Arbitrated resp resources */ 548 uint8_t rc_rdma_ra_out; /* Arbitrated initiator depth */ 549 ibt_arej_info_t rc_arej_info; 550 ibt_cm_reason_t rc_status; 551 uint8_t rc_failover_status; /* Failover status */ 552 ibt_priv_data_len_t rc_priv_data_len; 553 void *rc_priv_data; 554 } ibt_rc_returns_t; 555 556 /* 557 * Define a callback function that can be used in Non-Blocking calls to 558 * ibt_recycle_rc(). 559 */ 560 561 typedef void (*ibt_recycle_handler_t)(ibt_status_t ibt_status, void *arg); 562 563 /* 564 * Define an optional return arguments structure from ibt_set_alt_path() 565 * This contains return parameters, when called in BLOCKING mode. 566 * 567 * ap_priv_data should be NULL or point to a buffer allocated by the caller, 568 * the size of which should be in ap_priv_data_len, where ap_priv_data_len <= 569 * IBT_APR_PRIV_DATA_SZ. 570 * The private data from APR is returned in ap_priv_data. 571 * The caller specifies amount of APR private data to be returned in 572 * ap_priv_data_len. 573 */ 574 typedef struct ibt_ap_returns_s { 575 ibt_ap_status_t ap_status; 576 boolean_t ap_arej_info_valid; 577 ibt_arej_info_t ap_arej_info; /* Only valid if redirect */ 578 ibt_priv_data_len_t ap_priv_data_len; 579 void *ap_priv_data; 580 } ibt_ap_returns_t; 581 582 /* 583 * UD remote destination attributes. 584 * 585 * ud_sid, ud_addr, ud_pkt_lt and ud_pkey_ix must be specified. 586 * These values can be as returned in an ibt_path_info_t struct from an 587 * ibt_get_paths() call. 588 * 589 * ud_priv_data should be NULL or point to a buffer allocated by the caller, 590 * the size of which is in ud_priv_data_len, where ud_priv_data_len <= 591 * IBT_SIDR_REQ_PRIV_DATA_SZ. 592 */ 593 typedef struct ibt_ud_dest_attr_s { 594 ib_svc_id_t ud_sid; /* Service ID */ 595 ibt_adds_vect_t *ud_addr; /* Address Info */ 596 uint16_t ud_pkey_ix; /* Pkey Index */ 597 ib_time_t ud_pkt_lt; 598 ibt_cm_ud_handler_t ud_cm_handler; /* An optional CM UD event */ 599 /* which must be NULL */ 600 /* if not specified. */ 601 void *ud_cm_private; /* First arg to ud_cm_handler */ 602 ibt_priv_data_len_t ud_priv_data_len; 603 void *ud_priv_data; /* SIDR REQ private data */ 604 } ibt_ud_dest_attr_t; 605 606 /* 607 * Define an optional UD return arguments structure. 608 * 609 * ud_priv_data should be NULL or point to a buffer allocated by the caller, 610 * the size of which should be in ud_priv_data_len, where ud_priv_data_len <= 611 * IBT_SIDR_REP_PRIV_DATA_SZ. 612 */ 613 typedef struct ibt_ud_returns_s { 614 ibt_sidr_status_t ud_status; 615 ibt_redirect_info_t ud_redirect; 616 ib_qpn_t ud_dqpn; /* Returned destination QPN */ 617 ib_qkey_t ud_qkey; /* Q_Key for destination QPN */ 618 ibt_priv_data_len_t ud_priv_data_len; 619 void *ud_priv_data; 620 } ibt_ud_returns_t; 621 622 /* 623 * Multicast group attributes 624 * Not specified attributes should be set to "NULL" or "0". 625 * Used by ibt_join_mcg()/ibt_query_mcg(). 626 * 627 * mc_qkey, mc_pkey, mc_flow, mc_tclass, mc_sl, mc_join_state are required for 628 * create - ibt_join_mcg(). 629 */ 630 typedef struct ibt_mcg_attr_s { 631 ib_gid_t mc_mgid; /* MGID */ 632 ib_gid_t mc_pgid; /* SGID of the end port being */ 633 /* added to the MCG. */ 634 ib_qkey_t mc_qkey; /* Q_Key */ 635 ib_pkey_t mc_pkey; /* Partition key for this MCG */ 636 ibt_mtu_req_t mc_mtu_req; /* MTU */ 637 ibt_srate_req_t mc_rate_req; /* Static rate */ 638 ibt_pkt_lt_req_t mc_pkt_lt_req; /* Packet Life Time Request */ 639 uint_t mc_flow:20; /* FlowLabel. */ 640 uint8_t mc_hop; /* HopLimit */ 641 uint8_t mc_tclass; /* Traffic Class. */ 642 uint8_t mc_sl:4; /* Service Level */ 643 uint8_t mc_scope:4, /* Multicast Address Scope */ 644 mc_join_state:4; /* FULL For create */ 645 ib_lid_t mc_opaque1; 646 } ibt_mcg_attr_t; 647 648 /* 649 * Multicast group attributes. 650 * returned by ibt_join_mcg()/ibt_query_mcg(). 651 */ 652 typedef struct ibt_mcg_info_s { 653 ibt_adds_vect_t mc_adds_vect; /* Address information */ 654 ib_mtu_t mc_mtu; /* MTU */ 655 ib_qkey_t mc_qkey; /* Q_Key */ 656 uint16_t mc_pkey_ix; /* Pkey Index */ 657 uint8_t mc_scope:4; /* Multicast Address Scope */ 658 clock_t mc_opaque2; 659 } ibt_mcg_info_t; 660 661 /* 662 * Define a callback function that can be used in Non-Blocking calls to 663 * ibt_join_mcg(). 664 */ 665 typedef void (*ibt_mcg_handler_t)(void *arg, ibt_status_t retval, 666 ibt_mcg_info_t *mcg_info_p); 667 668 669 /* 670 * Service Flags - sd_flags 671 * 672 * IBT_SRV_PEER_TYPE_SID Peer-to-peer Service IDs. 673 */ 674 675 typedef enum ibt_service_flags_e { 676 IBT_SRV_NO_FLAGS = 0x0, 677 IBT_SRV_PEER_TYPE_SID = 0x1 678 } ibt_service_flags_t; 679 680 /* 681 * Define a Service ID Registration structure. 682 */ 683 typedef struct ibt_srv_desc_s { 684 ibt_cm_ud_handler_t sd_ud_handler; /* UD Service Handler */ 685 ibt_cm_handler_t sd_handler; /* Non-UD Service Handler */ 686 ibt_service_flags_t sd_flags; /* Flags */ 687 } ibt_srv_desc_t; 688 689 /* 690 * Flag to indicate ibt_bind_service() to or NOT-to clean-up Stale matching 691 * Local Service Records with SA prior to binding the new request. 692 */ 693 #define IBT_SBIND_NO_FLAGS 0 694 #define IBT_SBIND_NO_CLEANUP 1 695 696 /* 697 * Define a Service ID Binding structure (data for service records). 698 */ 699 typedef struct ibt_srv_bind_s { 700 uint64_t sb_key[2]; /* Service Key */ 701 char *sb_name; /* Service Name (up to 63 chars) */ 702 uint32_t sb_lease; /* Service Lease period (in seconds) */ 703 ib_pkey_t sb_pkey; /* Service P_Key */ 704 ibt_srv_data_t sb_data; /* Service Data */ 705 uint_t sb_flag; /* indicates to/not-to clean-up stale */ 706 /* matching local service records. */ 707 } ibt_srv_bind_t; 708 709 /* 710 * ibt_cm_delay() flags. 711 * 712 * Refer to InfiniBand Architecture Release Volume 1 Rev 1.0a: 713 * Section 12.6.6 MRA 714 */ 715 typedef enum ibt_cmdelay_flags_e { 716 IBT_CM_DELAY_REQ = 0, 717 IBT_CM_DELAY_REP = 1, 718 IBT_CM_DELAY_LAP = 2 719 } ibt_cmdelay_flags_t; 720 721 /* 722 * The payload for DDI events passed on IB_PROP_UPDATE_EVENT. 723 * This is passed as the bus nexus data to event_handler(9e). 724 */ 725 typedef struct ibt_prop_update_payload_s { 726 union { 727 struct { 728 uint32_t srv_updated:1; 729 uint32_t gid_updated:1; 730 } _ib_prop_update_struct; 731 uint32_t prop_updated; 732 } _ib_prop_update_union; 733 ibt_status_t ib_reprobe_status; 734 735 #define ib_srv_prop_updated \ 736 _ib_prop_update_union._ib_prop_update_struct.srv_updated 737 #define ib_gid_prop_updated \ 738 _ib_prop_update_union._ib_prop_update_struct.gid_updated 739 #define ib_prop_updated \ 740 _ib_prop_update_union.prop_updated 741 } ibt_prop_update_payload_t; 742 743 744 /* 745 * FUNCTION PROTOTYPES. 746 */ 747 748 /* 749 * ibt_attach() and ibt_detach(): 750 * These are the calls into IBTF used during client driver attach() and 751 * detach(). 752 * 753 * The IBTF returns an ibt_clnt_hdl_t to the client. This handle is used 754 * to identify this client device in all subsequent calls into the IBTF. 755 * 756 * The ibt_detach() routine is called from a client driver's detach() 757 * routine to deregister itself from the IBTF. 758 */ 759 ibt_status_t ibt_attach(ibt_clnt_modinfo_t *mod_infop, dev_info_t *arg, 760 void *clnt_private, ibt_clnt_hdl_t *ibt_hdl_p); 761 762 ibt_status_t ibt_detach(ibt_clnt_hdl_t ibt_hdl); 763 764 /* 765 * HCA FUNCTIONS 766 */ 767 768 /* 769 * ibt_get_hca_list() 770 * Returns the number of HCAs in a system and their node GUIDS. 771 * 772 * If hca_list_p is not NULL then the memory for the array of GUIDs is 773 * allocated by the IBTF and should be freed by the caller using 774 * ibt_free_hca_list(). If hca_list_p is NULL then no memory is allocated 775 * by ibt_get_hca_list and only the number of HCAs in a system is returned. 776 * 777 * It is assumed that the caller can block in kmem_alloc. 778 * 779 * ibt_free_hca_list() 780 * Free the memory allocated by ibt_get_hca_list(). 781 */ 782 uint_t ibt_get_hca_list(ib_guid_t **hca_list_p); 783 784 void ibt_free_hca_list(ib_guid_t *hca_list, uint_t entries); 785 786 /* 787 * ibt_open_hca() - Open/Close a HCA. HCA can only be opened/closed 788 * ibt_close_hca() once. ibt_open_hca() takes a client's ibt handle 789 * and a GUID and returns a unique IBT client HCA 790 * handle. 791 * 792 * These routines can not be called from interrupt context. 793 */ 794 ibt_status_t ibt_open_hca(ibt_clnt_hdl_t ibt_hdl, ib_guid_t hca_guid, 795 ibt_hca_hdl_t *hca_hdl); 796 797 ibt_status_t ibt_close_hca(ibt_hca_hdl_t hca_hdl); 798 799 800 /* 801 * ibt_query_hca() 802 * ibt_query_hca_byguid() 803 * Returns the static attributes of the specified HCA 804 */ 805 ibt_status_t ibt_query_hca(ibt_hca_hdl_t hca_hdl, ibt_hca_attr_t *hca_attrs); 806 807 ibt_status_t ibt_query_hca_byguid(ib_guid_t hca_guid, 808 ibt_hca_attr_t *hca_attrs); 809 810 811 /* 812 * ibt_query_hca_ports() 813 * ibt_query_hca_ports_byguid() 814 * Returns HCA port/ports attributes for the specified HCA port/ports. 815 * ibt_query_hca_ports() allocates the memory required for the 816 * ibt_hca_portinfo_t struct as well as the memory required for the SGID 817 * and P_Key tables contained within that struct. 818 * 819 * ibt_free_portinfo() 820 * Frees the memory allocated for a specified ibt_hca_portinfo_t struct. 821 */ 822 ibt_status_t ibt_query_hca_ports(ibt_hca_hdl_t hca_hdl, uint8_t port, 823 ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p); 824 825 ibt_status_t ibt_query_hca_ports_byguid(ib_guid_t hca_guid, uint8_t port, 826 ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p); 827 828 void ibt_free_portinfo(ibt_hca_portinfo_t *port_info, uint_t size); 829 830 /* 831 * ibt_set_hca_private() - Set/get the client private data. 832 * ibt_get_hca_private() 833 */ 834 void ibt_set_hca_private(ibt_hca_hdl_t hca_hdl, void *clnt_private); 835 void *ibt_get_hca_private(ibt_hca_hdl_t hca_hdl); 836 837 /* 838 * ibt_hca_handle_to_guid() 839 * A helper function to retrieve HCA GUID for the specified handle. 840 * Returns HCA GUID on which the specified Channel is allocated. Valid 841 * if it is non-NULL on return. 842 */ 843 ib_guid_t ibt_hca_handle_to_guid(ibt_hca_hdl_t hca); 844 845 /* 846 * ibt_hca_guid_to_handle() 847 * A helper function to retrieve a hca handle from a HCA GUID. 848 */ 849 ibt_status_t ibt_hca_guid_to_handle(ibt_clnt_hdl_t ibt_hdl, ib_guid_t hca_guid, 850 ibt_hca_hdl_t *hca_hdl); 851 852 /* 853 * CONNECTION ESTABLISHMENT/TEAR DOWN FUNCTIONS. 854 */ 855 856 /* 857 * ibt_get_paths 858 * Finds the best path to a specified destination (as determined by the 859 * IBTL) that satisfies the requirements specified in an ibt_path_attr_t 860 * struct. 861 */ 862 ibt_status_t ibt_get_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags, 863 ibt_path_attr_t *attr, uint8_t max_paths, ibt_path_info_t *paths, 864 uint8_t *num_paths_p); 865 866 867 /* 868 * Callback function that can be used in ibt_aget_paths(), a Non-Blocking 869 * version of ibt_get_paths(). 870 */ 871 typedef void (*ibt_path_handler_t)(void *arg, ibt_status_t retval, 872 ibt_path_info_t *paths, uint8_t num_paths); 873 874 /* 875 * Find path(s) to a given destination or service asynchronously. 876 * ibt_aget_paths() is a Non-Blocking version of ibt_get_paths(). 877 */ 878 ibt_status_t ibt_aget_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags, 879 ibt_path_attr_t *attr, uint8_t max_paths, ibt_path_handler_t func, 880 void *arg); 881 882 /* 883 * ibt_get_alt_path 884 * Finds the best alternate path to a specified channel (as determined by 885 * the IBTL) that satisfies the requirements specified in an 886 * ibt_alt_path_attr_t struct. The specified channel must have been 887 * previously opened successfully using ibt_open_rc_channel. 888 */ 889 ibt_status_t ibt_get_alt_path(ibt_channel_hdl_t chan, ibt_path_flags_t flags, 890 ibt_alt_path_attr_t *attr, ibt_alt_path_info_t *alt_path); 891 892 /* 893 * ibt_open_rc_channel 894 * ibt_open_rc_channel() opens a previously allocated RC communication 895 * channel. The IBTL initiates the channel establishment protocol. 896 */ 897 ibt_status_t ibt_open_rc_channel(ibt_channel_hdl_t rc_chan, 898 ibt_chan_open_flags_t flags, ibt_execution_mode_t mode, 899 ibt_chan_open_args_t *args, ibt_rc_returns_t *returns); 900 901 /* 902 * ibt_close_rc_channel 903 * Close the specified channel. Outstanding work requests are flushed 904 * so that the client can do the associated clean up. After that, the 905 * client will usually deregister the previously registered memory, 906 * then free the channel by calling ibt_free_rc_channel(). 907 * 908 * This function will reuse CM event Handler provided in 909 * ibt_open_rc_channel(). 910 */ 911 ibt_status_t ibt_close_rc_channel(ibt_channel_hdl_t rc_chan, 912 ibt_execution_mode_t mode, void *priv_data, 913 ibt_priv_data_len_t priv_data_len, uint8_t *ret_status, 914 void *ret_priv_data, ibt_priv_data_len_t *ret_priv_data_len_p); 915 916 /* 917 * ibt_prime_close_rc_channel 918 * 919 * Allocates resources required for a close rc channel operation. 920 * Calling ibt_prime_close_rc_channel() allows a channel to be 921 * subsequently closed in interrupt context. 922 * 923 * A call is first made to ibt_prime_close_rc_channel in non-interrupt 924 * context, followed by ibt_close_rc_channel in non-blocking mode from 925 * interrupt context 926 * 927 * ibt_prime_close_rc_channel() can only be called on a previously opened 928 * channel. 929 */ 930 ibt_status_t ibt_prime_close_rc_channel(ibt_channel_hdl_t rc_chan); 931 932 /* 933 * ibt_recycle_rc 934 * 935 * Recycle a RC channel which has transitioned to Error state. The 936 * ibt_recycle_rc() function transitions the channel from Error 937 * state (IBT_STATE_ERROR) to the state ready for use by 938 * ibt_open_rc_channel. Basically, this function is very similar to 939 * ibt_alloc_rc_channel, but reuses an existing RC channel. 940 * 941 * Clients are allowed to make resource clean up/free calls in the CM handler 942 * 943 * Client(s) must not invoke blocking version (ie., func specified as NULL) of 944 * ibt_recycle_rc from cm callback for IBT_CM_EVENT_CONN_CLOSED 945 * 946 * Clients are strongly advised not to issue blocking calls from func, as this 947 * would block the CM threads, and could delay or block other client connections 948 * and ibtl related API invocations. 949 */ 950 ibt_status_t ibt_recycle_rc(ibt_channel_hdl_t rc_chan, ibt_cep_flags_t control, 951 uint8_t hca_port_num, ibt_recycle_handler_t func, void *arg); 952 953 /* 954 * ibt_recycle_ud 955 * 956 * Recycle a UD channel which has transitioned to Error state. The 957 * ibt_recycle_ud() function transitions the channel from Error 958 * state (IBT_STATE_ERROR) to a usable state (IBT_STATE_RTS). 959 * Basically, this function is very similar to ibt_alloc_ud_channel, 960 * but reuses an existing UD channel. 961 */ 962 ibt_status_t ibt_recycle_ud(ibt_channel_hdl_t ud_chan, uint8_t hca_port_num, 963 uint16_t pkey_ix, ib_qkey_t qkey); 964 965 /* 966 * MODIFY CHANNEL ATTRIBUTE FUNCTIONs. 967 */ 968 969 /* 970 * ibt_pause_sendq 971 * ibt_unpause_sendq 972 * Place the send queue of the specified channel into the send queue 973 * drained state. 974 * Applicable for both RC and UD channels. 975 */ 976 ibt_status_t ibt_pause_sendq(ibt_channel_hdl_t chan, 977 ibt_cep_modify_flags_t modify_flags); 978 979 ibt_status_t ibt_unpause_sendq(ibt_channel_hdl_t chan); 980 981 /* 982 * ibt_resize_queues() 983 * Resize the SendQ/RecvQ sizes of a channel. 984 * 985 * Applicable for both RC and UD channels. 986 */ 987 ibt_status_t ibt_resize_queues(ibt_channel_hdl_t chan, ibt_qflags_t flags, 988 ibt_queue_sizes_t *request_sz, ibt_queue_sizes_t *actual_sz); 989 990 /* 991 * ibt_query_queues() 992 * 993 * Query the SendQ/RecvQ sizes of a channel. 994 * Applicable for both RC and UD channels. 995 */ 996 ibt_status_t ibt_query_queues(ibt_channel_hdl_t chan, 997 ibt_queue_sizes_t *actual_sz); 998 999 /* 1000 * ibt_modify_rdma 1001 * Enable/disable RDMA operations. 1002 * 1003 * Applicable for RC channels only. 1004 */ 1005 ibt_status_t ibt_modify_rdma(ibt_channel_hdl_t rc_chan, 1006 ibt_cep_modify_flags_t modify_flags, ibt_cep_flags_t flags); 1007 1008 1009 /* 1010 * ibt_set_rdma_resource 1011 * Change the number of resources to be used for incoming and outgoing 1012 * RDMA reads & Atomics. 1013 */ 1014 ibt_status_t ibt_set_rdma_resource(ibt_channel_hdl_t rc_chan, 1015 ibt_cep_modify_flags_t modify_flags, uint8_t rdma_ra_out, 1016 uint8_t rdma_ra_in); 1017 1018 /* 1019 * ibt_change_port 1020 * Change the primary physical port of an RC channel. (This is done only 1021 * if HCA supports this capability). Can only be called on a paused 1022 * channel. 1023 * Applicable for RC channels only. 1024 */ 1025 ibt_status_t ibt_change_port(ibt_channel_hdl_t rc_chan, uint8_t port_num); 1026 1027 1028 /* 1029 * SERVICE REGISTRATION FUNCTIONS 1030 */ 1031 1032 /* 1033 * ibt_register_service() 1034 * ibt_deregister_service() 1035 * Register/deregister a Service (range of Service IDs) with the IBTF. 1036 * 1037 * ibt_bind_service() 1038 * ibt_unbind_service() 1039 * ibt_unbind_all_services() 1040 * Bind a Service to a given port (GID), and optionally create 1041 * service record(s) with the SA for ibt_get_paths() to find. 1042 */ 1043 ibt_status_t ibt_register_service(ibt_clnt_hdl_t ibt_hdl, 1044 ibt_srv_desc_t *service, ib_svc_id_t sid, int num_sids, 1045 ibt_srv_hdl_t *srv_hdl_p, ib_svc_id_t *ret_sid_p); 1046 1047 ibt_status_t ibt_deregister_service(ibt_clnt_hdl_t ibt_hdl, 1048 ibt_srv_hdl_t srv_hdl); 1049 1050 ibt_status_t ibt_bind_service(ibt_srv_hdl_t srv_hdl, ib_gid_t gid, 1051 ibt_srv_bind_t *srv_bind, void *cm_private, ibt_sbind_hdl_t *sb_hdl_p); 1052 1053 ibt_status_t ibt_unbind_service(ibt_srv_hdl_t srv_hdl, ibt_sbind_hdl_t sb_hdl); 1054 ibt_status_t ibt_unbind_all_services(ibt_srv_hdl_t srv_hdl); 1055 1056 /* 1057 * ibt_cm_delay 1058 * A client CM handler/srv_handler function can call this function to 1059 * extend its response time to a CM event. 1060 * Applicable for RC channels only. 1061 */ 1062 ibt_status_t ibt_cm_delay(ibt_cmdelay_flags_t flags, void *cm_session_id, 1063 clock_t service_time, void *priv_data, ibt_priv_data_len_t priv_data_len); 1064 1065 /* 1066 * ibt_cm_proceed 1067 * 1068 * An IBT client calls ibt_cm_proceed() to proceed with a connection that 1069 * previously deferred by the client returning IBT_CM_DEFER on a CM handler 1070 * callback. CM events that can be deferred and continued with ibt_cm_proceed() 1071 * are REQ_RCV, REP_RCV, LAP_RCV, and DREQ_RCV. 1072 * 1073 * NOTE : 1074 * 1075 * Typically CM completes processing of a client's CM handler return, with 1076 * IBT_CM_DEFER status, before processing of the corresponding ibt_cm_proceed() 1077 * is started. However a race exists where by CM may not have completed the 1078 * client's handler return processing when ibt_cm_proceed() is called by a 1079 * client. In this case ibt_cm_proceed() will block until processing of the 1080 * client's CM handler return is complete. 1081 * 1082 * A client that returns IBT_CM_DEFER from the cm handler must 1083 * subsequently make a call to ibt_cm_proceed(). It is illegal to call 1084 * ibt_cm_proceed() on a channel that has not had the connection 1085 * establishment deferred. 1086 * 1087 * Client cannot call ibt_cm_proceed from the cm handler. 1088 */ 1089 ibt_status_t ibt_cm_proceed(ibt_cm_event_type_t event, void *session_id, 1090 ibt_cm_status_t status, ibt_cm_proceed_reply_t *cm_event_data, 1091 void *priv_data, ibt_priv_data_len_t priv_data_len); 1092 1093 /* 1094 * ibt_cm_ud_proceed 1095 * 1096 * An IBT client calls ibt_cm_ud_proceed() to proceed with an 1097 * IBT_CM_UD_EVENT_SIDR_REQ UD event that was previously deferred by the 1098 * client returning IBT_CM_DEFER on a CM UD handler callback. 1099 * NOTE : 1100 * 1101 * Typically CM completes processing of a client's CM handler return, with 1102 * IBT_CM_DEFER status, before processing of the corresponding 1103 * ibt_cm_ud_proceed() is started. However a race exists where by CM may not 1104 * have completed the client's handler return processing when 1105 * ibt_cm_ud_proceed() is called by a client. In this case ibt_cm_ud_proceed() 1106 * will block until processing of the client's CM handler return is complete. 1107 * 1108 * A client that returns IBT_CM_DEFER from the cm handler must 1109 * subsequently make a call to ibt_cm_ud_proceed(). It is illegal to call 1110 * ibt_cm_ud_proceed() on a channel that has not had the connection 1111 * establishment deferred. 1112 * 1113 * Client cannot call ibt_cm_ud_proceed from the cm handler. 1114 */ 1115 ibt_status_t ibt_cm_ud_proceed(void *session_id, ibt_channel_hdl_t ud_channel, 1116 ibt_cm_status_t status, ibt_redirect_info_t *redirect_infop, 1117 void *priv_data, ibt_priv_data_len_t priv_data_len); 1118 1119 1120 /* 1121 * COMPLETION QUEUES. 1122 * 1123 * ibt_alloc_cq_sched() 1124 * Reserve CQ scheduling class resources 1125 * 1126 * ibt_free_cq_sched() 1127 * Free CQ scheduling class resources 1128 */ 1129 ibt_status_t ibt_alloc_cq_sched(ibt_hca_hdl_t hca_hdl, 1130 ibt_cq_sched_attr_t *attr, ibt_sched_hdl_t *sched_hdl_p); 1131 1132 ibt_status_t ibt_free_cq_sched(ibt_hca_hdl_t hca_hdl, 1133 ibt_sched_hdl_t sched_hdl, uint_t load); 1134 1135 /* 1136 * ibt_alloc_cq() 1137 * Allocate a completion queue. 1138 */ 1139 ibt_status_t ibt_alloc_cq(ibt_hca_hdl_t hca_hdl, ibt_cq_attr_t *cq_attr, 1140 ibt_cq_hdl_t *ibt_cq_p, uint_t *real_size); 1141 1142 /* 1143 * ibt_free_cq() 1144 * Free allocated CQ resources. 1145 */ 1146 ibt_status_t ibt_free_cq(ibt_cq_hdl_t ibt_cq); 1147 1148 1149 /* 1150 * ibt_enable_cq_notify() 1151 * Enable notification requests on the specified CQ. 1152 * Applicable for both RC and UD channels. 1153 * 1154 * Completion notifications are disabled by setting the completion 1155 * handler to NULL by calling ibt_set_cq_handler(). 1156 */ 1157 ibt_status_t ibt_enable_cq_notify(ibt_cq_hdl_t ibt_cq, 1158 ibt_cq_notify_flags_t notify_type); 1159 1160 /* 1161 * ibt_set_cq_handler() 1162 * Register a work request completion handler with the IBTF. 1163 * Applicable for both RC and UD channels. 1164 * 1165 * Completion notifications are disabled by setting the completion 1166 * handler to NULL. When setting the handler to NULL, no additional 1167 * calls to the CQ handler will be initiated. 1168 * 1169 * This function does not otherwise change the state of previous 1170 * calls to ibt_enable_cq_notify(). 1171 */ 1172 void ibt_set_cq_handler(ibt_cq_hdl_t ibt_cq, 1173 ibt_cq_handler_t completion_handler, void *arg); 1174 1175 /* 1176 * ibt_poll_cq() 1177 * Poll the specified CQ for the completion of work requests (WRs). 1178 * If the CQ contains completed WRs, up to num_wc of them are returned. 1179 * Applicable for both RC and UD channels. 1180 */ 1181 ibt_status_t ibt_poll_cq(ibt_cq_hdl_t ibt_cq, ibt_wc_t *work_completions, 1182 uint_t num_wc, uint_t *num_polled); 1183 1184 /* 1185 * ibt_query_cq() 1186 * Return the total number of entries in the CQ. 1187 */ 1188 ibt_status_t ibt_query_cq(ibt_cq_hdl_t ibt_cq, uint_t *entries); 1189 1190 /* 1191 * ibt_resize_cq() 1192 * Change the size of a CQ. 1193 */ 1194 ibt_status_t ibt_resize_cq(ibt_cq_hdl_t ibt_cq, uint_t new_sz, uint_t *real_sz); 1195 1196 /* 1197 * ibt_set_cq_private() 1198 * ibt_get_cq_private() 1199 * Set/get the client private data. 1200 */ 1201 void ibt_set_cq_private(ibt_cq_hdl_t ibt_cq, void *clnt_private); 1202 void *ibt_get_cq_private(ibt_cq_hdl_t ibt_cq); 1203 1204 1205 /* 1206 * Memory Management Functions. 1207 * Applicable for both RC and UD channels. 1208 * 1209 * ibt_register_mr() 1210 * Prepares a virtually addressed memory region for use by a HCA. A 1211 * description of the registered memory suitable for use in Work Requests 1212 * (WRs) is returned in the ibt_mr_desc_t parameter. 1213 * 1214 * ibt_register_buf() 1215 * Prepares a memory region described by a buf(9S) struct for use by a 1216 * HCA. A description of the registered memory suitable for use in 1217 * Work Requests (WRs) is returned in the ibt_mr_desc_t parameter. 1218 * 1219 * ibt_query_mr() 1220 * Retrieves information about a specified memory region. 1221 * 1222 * ibt_deregister_mr() 1223 * Remove a memory region from a HCA translation table, and free all 1224 * resources associated with the memory region. 1225 * 1226 * ibt_reregister_mr() 1227 * ibt_reregister_buf() 1228 * Modify the attributes of an existing memory region. 1229 * 1230 * ibt_register_shared_mr() 1231 * Given an existing memory region, a new memory region associated with 1232 * the same physical locations is created. 1233 * 1234 * ibt_sync_mr() 1235 * Sync a memory region for either RDMA reads or RDMA writes 1236 * 1237 * ibt_alloc_mw() 1238 * Allocate a memory window. 1239 * 1240 * ibt_query_mw() 1241 * Retrieves information about a specified memory window. 1242 * 1243 * ibt_free_mw() 1244 * De-allocate the Memory Window. 1245 */ 1246 ibt_status_t ibt_register_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, 1247 ibt_mr_attr_t *mem_attr, ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc); 1248 1249 ibt_status_t ibt_register_buf(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, 1250 ibt_smr_attr_t *mem_bpattr, struct buf *bp, ibt_mr_hdl_t *mr_hdl_p, 1251 ibt_mr_desc_t *mem_desc); 1252 1253 ibt_status_t ibt_query_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 1254 ibt_mr_query_attr_t *attr); 1255 1256 ibt_status_t ibt_deregister_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl); 1257 1258 ibt_status_t ibt_reregister_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 1259 ibt_pd_hdl_t pd, ibt_mr_attr_t *mem_attr, ibt_mr_hdl_t *mr_hdl_p, 1260 ibt_mr_desc_t *mem_desc); 1261 1262 ibt_status_t ibt_reregister_buf(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 1263 ibt_pd_hdl_t pd, ibt_smr_attr_t *mem_bpattr, struct buf *bp, 1264 ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc); 1265 1266 ibt_status_t ibt_register_shared_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 1267 ibt_pd_hdl_t pd, ibt_smr_attr_t *mem_sattr, ibt_mr_hdl_t *mr_hdl_p, 1268 ibt_mr_desc_t *mem_desc); 1269 1270 ibt_status_t ibt_sync_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_sync_t *mr_segments, 1271 size_t num_segments); 1272 1273 ibt_status_t ibt_alloc_mw(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, 1274 ibt_mw_flags_t flags, ibt_mw_hdl_t *mw_hdl_p, ibt_rkey_t *rkey); 1275 1276 ibt_status_t ibt_query_mw(ibt_hca_hdl_t hca_hdl, ibt_mw_hdl_t mw_hdl, 1277 ibt_mw_query_attr_t *mw_attr_p); 1278 1279 ibt_status_t ibt_free_mw(ibt_hca_hdl_t hca_hdl, ibt_mw_hdl_t mw_hdl); 1280 1281 /* 1282 * ibt_alloc_lkey() 1283 * Allocates physical buffer list resources for use in memory 1284 * registrations. 1285 * 1286 * Applicable for both RC and UD channels. 1287 */ 1288 ibt_status_t ibt_alloc_lkey(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, 1289 ibt_lkey_flags_t flags, uint_t phys_buf_list_sz, ibt_mr_hdl_t *mr_p, 1290 ibt_pmr_desc_t *mem_desc_p); 1291 1292 1293 /* 1294 * Physical Memory Management Functions. 1295 * Applicable for both RC and UD channels. 1296 * 1297 * ibt_register_phys_mr() 1298 * Prepares a physically addressed memory region for use by a HCA. 1299 * 1300 * ibt_reregister_phys_mr() 1301 * Modify the attributes of an existing memory region. 1302 */ 1303 ibt_status_t ibt_register_phys_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, 1304 ibt_pmr_attr_t *mem_pattr, ibt_mr_hdl_t *mr_hdl_p, 1305 ibt_pmr_desc_t *mem_desc_p); 1306 1307 ibt_status_t ibt_reregister_phys_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 1308 ibt_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr, ibt_mr_hdl_t *mr_hdl_p, 1309 ibt_pmr_desc_t *mem_desc_p); 1310 1311 1312 /* 1313 * Address Translation. 1314 */ 1315 1316 /* 1317 * ibt_map_mem_area() 1318 * Translate a kernel virtual address range into HCA physical addresses. 1319 * A set of physical addresses, that can be used with "Reserved L_Key", 1320 * register physical, and "Fast Registration Work Request" operations 1321 * is returned. 1322 */ 1323 ibt_status_t ibt_map_mem_area(ibt_hca_hdl_t hca_hdl, ibt_va_attr_t *va_attrs, 1324 uint_t paddr_list_len, ibt_phys_buf_t *paddr_list_p, uint_t *num_paddr_p, 1325 size_t *paddr_bufsz_p, ib_memlen_t *paddr_offset_p, ibt_ma_hdl_t *ma_hdl_p); 1326 1327 /* 1328 * ibt_unmap_mem_area() 1329 * Un pin physical pages pinned during an ibt_map_mem_area() call. 1330 */ 1331 ibt_status_t ibt_unmap_mem_area(ibt_hca_hdl_t hca_hdl, ibt_ma_hdl_t ma_hdl); 1332 1333 /* 1334 * Work Request Functions 1335 * Applicable for RC and UD channels. 1336 * 1337 * ibt_post_send() 1338 * Post send work requests to the specified channel. 1339 * 1340 * ibt_post_recv() 1341 * ibt_post_srq() 1342 * Post receive work requests to the specified channel. 1343 */ 1344 ibt_status_t ibt_post_send(ibt_channel_hdl_t chan, ibt_send_wr_t *wr_list, 1345 uint_t num_wr, uint_t *posted); 1346 1347 ibt_status_t ibt_post_recv(ibt_channel_hdl_t chan, ibt_recv_wr_t *wr_list, 1348 uint_t num_wr, uint_t *posted); 1349 1350 ibt_status_t ibt_post_srq(ibt_srq_hdl_t srq, ibt_recv_wr_t *wr_list, 1351 uint_t num_wr, uint_t *posted); 1352 1353 1354 /* 1355 * Alternate Path Migration Functions. 1356 * Applicable for RC channels only. 1357 * 1358 * 1359 * ibt_get_alt_path() 1360 * Finds the best alternate path to a specified channel (as determined by 1361 * the IBTL) that satisfies the requirements specified in an 1362 * ibt_alt_path_attr_t struct. The specified channel must have been 1363 * previously opened successfully using ibt_open_rc_channel. 1364 * This function also ensures that the service being accessed by the 1365 * channel is available at the selected alternate port. 1366 * 1367 * Note: The apa_dgid must be on the same destination channel adapter, 1368 * if specified. 1369 * 1370 * 1371 * ibt_set_alt_path() 1372 * Load the specified alternate path. Causes the CM to send an LAP message 1373 * to the remote node. If successful, the local channel is updated with 1374 * the new alternate path and the channel migration state is set to REARM. 1375 * Can only be called on a previously opened RC channel. The channel must 1376 * be either in RTS or paused state. 1377 * 1378 * 1379 * ibt_migrate_path() 1380 * Force the CI to use the alternate path. The alternate path becomes 1381 * the primary path. A new alternate path should be loaded and enabled. 1382 */ 1383 ibt_status_t ibt_get_alt_path(ibt_channel_hdl_t rc_chan, ibt_path_flags_t flags, 1384 ibt_alt_path_attr_t *attr, ibt_alt_path_info_t *alt_pathp); 1385 1386 ibt_status_t ibt_set_alt_path(ibt_channel_hdl_t rc_chan, 1387 ibt_execution_mode_t mode, ibt_alt_path_info_t *alt_pinfo, void *priv_data, 1388 ibt_priv_data_len_t priv_data_len, ibt_ap_returns_t *ret_args); 1389 1390 ibt_status_t ibt_migrate_path(ibt_channel_hdl_t rc_chan); 1391 1392 1393 /* 1394 * Multicast group Functions. 1395 * Applicable for UD channels only. 1396 */ 1397 1398 /* 1399 * ibt_attach_mcg() 1400 * Attaches a UD channel to the specified multicast group. On successful 1401 * completion, this channel will be provided with a copy of every 1402 * multicast message addressed to the group specified by the MGID 1403 * (mcg_info->mc_adds_vect.av_dgid) and received on the HCA port with 1404 * which the channel is associated. 1405 */ 1406 ibt_status_t ibt_attach_mcg(ibt_channel_hdl_t ud_chan, 1407 ibt_mcg_info_t *mcg_info); 1408 1409 /* 1410 * ibt_detach_mcg() 1411 * Detach the specified UD channel from the specified multicast group. 1412 */ 1413 ibt_status_t ibt_detach_mcg(ibt_channel_hdl_t ud_chan, 1414 ibt_mcg_info_t *mcg_info); 1415 1416 /* 1417 * ibt_join_mcg() 1418 * Join a multicast group. The first full member "join" causes the MCG 1419 * to be created. 1420 */ 1421 ibt_status_t ibt_join_mcg(ib_gid_t rgid, ibt_mcg_attr_t *mcg_attr, 1422 ibt_mcg_info_t *mcg_info_p, ibt_mcg_handler_t func, void *arg); 1423 1424 /* 1425 * ibt_leave_mcg() 1426 * The port associated with the port GID shall be removed from the 1427 * multicast group specified by MGID (mc_gid) or from all the multicast 1428 * groups of which it is a member if the MGID (mc_gid) is not specified 1429 * (i.e. mc_gid.mgid_prefix must have 8-bits of 11111111 at the start of 1430 * the GID to identify this as being a multicast GID). 1431 * 1432 * The last full member to leave causes the destruction of the Multicast 1433 * Group. 1434 */ 1435 ibt_status_t ibt_leave_mcg(ib_gid_t rgid, ib_gid_t mc_gid, ib_gid_t port_gid, 1436 uint8_t mc_join_state); 1437 1438 /* 1439 * ibt_query_mcg() 1440 * Request information on multicast groups that match the parameters 1441 * specified in mcg_attr. Information on each multicast group is returned 1442 * to the caller in the form of an array of ibt_mcg_info_t. 1443 * ibt_query_mcg() allocates the memory for this array and returns a 1444 * pointer to the array (mcgs_p) and the number of entries in the array 1445 * (entries_p). This memory should be freed by the client using 1446 * ibt_free_mcg_info(). 1447 */ 1448 ibt_status_t ibt_query_mcg(ib_gid_t rgid, ibt_mcg_attr_t *mcg_attr, 1449 uint_t mcgs_max_num, ibt_mcg_info_t **mcgs_info_p, uint_t *entries_p); 1450 1451 /* 1452 * ibt_free_mcg_info() 1453 * Free the memory allocated by successful ibt_query_mcg() 1454 */ 1455 void ibt_free_mcg_info(ibt_mcg_info_t *mcgs_info, uint_t entries); 1456 1457 1458 /* 1459 * ibt_register_subnet_notices() 1460 * Register a handler to be called for subnet notifications. 1461 */ 1462 void ibt_register_subnet_notices(ibt_clnt_hdl_t ibt_hdl, 1463 ibt_sm_notice_handler_t sm_notice_handler, void *private); 1464 1465 1466 /* 1467 * Protection Domain Functions. 1468 * 1469 * ibt_alloc_pd() 1470 * ibt_free_pd() 1471 * Allocate/Release a protection domain 1472 */ 1473 ibt_status_t ibt_alloc_pd(ibt_hca_hdl_t hca_hdl, ibt_pd_flags_t flags, 1474 ibt_pd_hdl_t *pd); 1475 ibt_status_t ibt_free_pd(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd); 1476 1477 /* 1478 * P_Key to P_Key Index conversion Functions. 1479 * 1480 * ibt_pkey2index_byguid 1481 * ibt_pkey2index Convert a P_Key into a P_Key index. 1482 * 1483 * ibt_index2pkey_byguid 1484 * ibt_index2pkey Convert a P_Key Index into a P_Key. 1485 */ 1486 ibt_status_t ibt_pkey2index(ibt_hca_hdl_t hca_hdl, uint8_t port_num, 1487 ib_pkey_t pkey, uint16_t *pkey_ix); 1488 1489 ibt_status_t ibt_index2pkey(ibt_hca_hdl_t hca_hdl, uint8_t port_num, 1490 uint16_t pkey_ix, ib_pkey_t *pkey); 1491 1492 ibt_status_t ibt_pkey2index_byguid(ib_guid_t hca_guid, uint8_t port_num, 1493 ib_pkey_t pkey, uint16_t *pkey_ix); 1494 1495 ibt_status_t ibt_index2pkey_byguid(ib_guid_t hca_guid, uint8_t port_num, 1496 uint16_t pkey_ix, ib_pkey_t *pkey); 1497 1498 /* 1499 * ibt_ci_data_in() 1500 * 1501 * Pass CI specific userland data for CI objects to the CI. 1502 */ 1503 ibt_status_t ibt_ci_data_in(ibt_hca_hdl_t hca, ibt_ci_data_flags_t flags, 1504 ibt_object_type_t object, void *ibt_object_handle, void *data_p, 1505 size_t data_sz); 1506 1507 /* 1508 * ibt_ci_data_out() 1509 * 1510 * Obtain CI specific userland data for CI objects. 1511 */ 1512 ibt_status_t ibt_ci_data_out(ibt_hca_hdl_t hca, ibt_ci_data_flags_t flags, 1513 ibt_object_type_t object, void *ibt_object_handle, void *data_p, 1514 size_t data_sz); 1515 1516 1517 /* 1518 * Node Information. 1519 */ 1520 1521 /* Node type : n_node_type */ 1522 #define IBT_NODE_TYPE_CHANNEL_ADAPTER 1 /* HCA or TCA */ 1523 #define IBT_NODE_TYPE_SWITCH 2 1524 #define IBT_NODE_TYPE_ROUTER 3 1525 1526 typedef struct ibt_node_info_s { 1527 ib_guid_t n_sys_img_guid; /* System Image GUID */ 1528 ib_guid_t n_node_guid; /* Node GUID */ 1529 ib_guid_t n_port_guid; /* Port GUID */ 1530 uint16_t n_dev_id; /* Device ID */ 1531 uint32_t n_revision; /* Device Revision */ 1532 uint32_t n_vendor_id:24; /* Device Vendor ID */ 1533 uint8_t n_num_ports; /* Number of ports on this node. */ 1534 uint8_t n_port_num; /* Port number. */ 1535 uint8_t n_node_type; /* Node type */ 1536 char n_description[64]; /* NULL terminated ASCII string */ 1537 } ibt_node_info_t; 1538 1539 1540 /* 1541 * ibt_gid_to_node_info() 1542 * Retrieve node information for the specified GID. 1543 */ 1544 ibt_status_t ibt_gid_to_node_info(ib_gid_t gid, ibt_node_info_t *node_info_p); 1545 1546 /* 1547 * ibt_reprobe_dev 1548 * Reprobe properties for IOC device node. 1549 */ 1550 ibt_status_t ibt_reprobe_dev(dev_info_t *dip); 1551 1552 /* 1553 * ibt_get_companion_port_gids() 1554 * 1555 * Get list of GID's available on a companion port(s) of the specified 1556 * GID or list of GIDs available on a specified Node GUID/System Image 1557 * GUID. 1558 */ 1559 ibt_status_t ibt_get_companion_port_gids(ib_gid_t gid, ib_guid_t hca_guid, 1560 ib_guid_t sysimg_guid, ib_gid_t **gids_p, uint_t *num_gids_p); 1561 1562 /* 1563 * SHARED RECEIVE QUEUE 1564 */ 1565 1566 1567 /* 1568 * ibt_alloc_srq() 1569 * Allocate a shared receive queue. 1570 */ 1571 ibt_status_t ibt_alloc_srq(ibt_hca_hdl_t hca_hdl, ibt_srq_flags_t flags, 1572 ibt_pd_hdl_t pd, ibt_srq_sizes_t *sizes, ibt_srq_hdl_t *ibt_srq_p, 1573 ibt_srq_sizes_t *real_size_p); 1574 1575 /* 1576 * ibt_free_srq() 1577 * Free allocated SRQ resources. 1578 */ 1579 ibt_status_t ibt_free_srq(ibt_srq_hdl_t ibt_srq); 1580 1581 /* 1582 * ibt_query_srq() 1583 * Query a shared receive queue. 1584 */ 1585 ibt_status_t ibt_query_srq(ibt_srq_hdl_t ibt_srq, ibt_pd_hdl_t *pd_p, 1586 ibt_srq_sizes_t *sizes_p, uint_t *limit_p); 1587 1588 /* 1589 * ibt_modify_srq() 1590 * Modify a shared receive queue. 1591 */ 1592 ibt_status_t ibt_modify_srq(ibt_srq_hdl_t ibt_srq, ibt_srq_modify_flags_t flags, 1593 uint_t size, uint_t limit, uint_t *real_size_p); 1594 1595 /* 1596 * ibt_set_srq_private() 1597 * ibt_get_srq_private() 1598 * Set/get the SRQ client private data. 1599 */ 1600 void ibt_set_srq_private(ibt_srq_hdl_t ibt_srq, void *clnt_private); 1601 void *ibt_get_srq_private(ibt_srq_hdl_t ibt_srq); 1602 1603 /* 1604 * ibt_check_failure() 1605 * Function to test for special case failures 1606 */ 1607 ibt_failure_type_t ibt_check_failure(ibt_status_t status, uint64_t *reserved_p); 1608 1609 1610 /* 1611 * ibt_hw_is_present() returns 0 when there is no IB hardware actively 1612 * running. This is primarily useful for modules like rpcmod which needs a 1613 * quick check to decide whether or not it should try to use InfiniBand. 1614 */ 1615 int ibt_hw_is_present(); 1616 1617 /* 1618 * Fast Memory Registration (FMR). 1619 * 1620 * ibt_create_fmr_pool 1621 * Not fast-path. 1622 * ibt_create_fmr_pool() verifies that the HCA supports FMR and allocates 1623 * and initializes an "FMR pool". This pool contains state specific to 1624 * this registration, including the watermark setting to determine when 1625 * to sync, and the total number of FMR regions available within this pool. 1626 * 1627 * ibt_destroy_fmr_pool 1628 * ibt_destroy_fmr_pool() deallocates all of the FMR regions in a specific 1629 * pool. All state and information regarding the pool are destroyed and 1630 * returned as free space once again. No more use of FMR regions in this 1631 * pool are possible without a subsequent call to ibt_create_fmr_pool(). 1632 * 1633 * ibt_flush_fmr_pool 1634 * ibt_flush_fmr_pool forces a flush to occur. At the client's request, 1635 * any unmapped FMR regions (See 'ibt_deregister_mr())') are returned to 1636 * a free state. This function allows for an asynchronous cleanup of 1637 * formerly used FMR regions. Sync operation is also performed internally 1638 * by HCA driver, when 'watermark' settings for the number of free FMR 1639 * regions left in the "pool" is reached. 1640 * 1641 * ibt_register_physical_fmr 1642 * ibt_register_physical_fmr() assigns a "free" entry from the FMR Pool. 1643 * It first consults the "FMR cache" to see if this is a duplicate memory 1644 * registration to something already in use. If not, then a free entry 1645 * in the "pool" is marked used. 1646 * 1647 * ibt_deregister_fmr 1648 * The ibt_deregister_fmr un-maps the resources reserved from the FMR 1649 * pool by ibt_register_physical_fmr(). The ibt_deregister_fmr() will 1650 * mark the region as free in the FMR Pool. 1651 */ 1652 ibt_status_t ibt_create_fmr_pool(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, 1653 ibt_fmr_pool_attr_t *fmr_params, ibt_fmr_pool_hdl_t *fmr_pool_p); 1654 1655 ibt_status_t ibt_destroy_fmr_pool(ibt_hca_hdl_t hca_hdl, 1656 ibt_fmr_pool_hdl_t fmr_pool); 1657 1658 ibt_status_t ibt_flush_fmr_pool(ibt_hca_hdl_t hca_hdl, 1659 ibt_fmr_pool_hdl_t fmr_pool); 1660 1661 ibt_status_t ibt_register_physical_fmr(ibt_hca_hdl_t hca_hdl, 1662 ibt_fmr_pool_hdl_t fmr_pool, ibt_pmr_attr_t *mem_pattr, 1663 ibt_mr_hdl_t *mr_hdl_p, ibt_pmr_desc_t *mem_desc_p); 1664 1665 ibt_status_t ibt_deregister_fmr(ibt_hca_hdl_t hca, ibt_mr_hdl_t mr_hdl); 1666 1667 /* 1668 * IP SUPPORT 1669 */ 1670 1671 /* 1672 * IP get_paths 1673 * Returns an array (or single) of paths and source IP addresses. In the 1674 * simplest form just the destination IP address is specified, and one path 1675 * is requested, then one ibt_path_info_t struct and one source IP. 1676 * 1677 * More than one path can be requested to a single destination, in which case 1678 * the requested number of ibt_path_info_t's are returned, and the same 1679 * number of SRC IP address, with the first SRC IP address corrosponding 1680 * to the first ibt_path_info_t, etc. 1681 * 1682 * Restrictions on the source end point can be specified, in the form of a 1683 * source IP address (this implicitly defines the HCA, HCA port and Pkey) 1684 * HCA, HCA port, and sgid (implicitly defines HCA and HCA port). 1685 * Combinations are allowed but they must be consistent. 1686 * 1687 * Path attributes can also be specified, these can also affect local HCA 1688 * selection. 1689 * 1690 * ibt_get_ip_paths() internally does (among other things): 1691 * 1692 * o ibt_get_list_of_ibd_ipaddr_and_macaddr( OUT list_ipaddr_macaddr) 1693 * 1694 * o extract_pkey_and_sgid(IN list_ipaddr_macaddr, OUT list_pkey_and_sgid) 1695 * 1696 * o map_dst_ip_addr(IN dst_ip_addr, OUT dst_pkey, OUT dgid) - See Note 1697 * 1698 * o filter_by_pkey(IN list_pkey_and_sgid, IN dst_pkey, OUT list_of_sgid) 1699 * 1700 * o do_multipath_query(IN list_of_sgid, IN dst_pkey, IN dgid, OUT path_list) 1701 * 1702 * o pick_a_good_path(IN path_list, OUT the_path) 1703 * 1704 * o find_matching_src_ip(IN the_path, IN list_ipaddr_macaddr, OUT src_ip) 1705 * 1706 * The ibd instance which got the ARP response is only on one P_Key 1707 * knowing the ibd instance (or which IPonIB MCG) got the ARP response 1708 * determins the P_Key associated with a dgid. If the proposedi "ip2mac()" 1709 * API is used to get an IP to GID translations, then returned 'sockaddr_dl' 1710 * contains the interface name and index. 1711 * 1712 * 1713 * Example: 1714 * ip_path_attr.ipa_dst_ip = dst_ip_addr; 1715 * ip_path_attr.ipa_ndst = 1; 1716 * ip_path_attr.ipa_max_paths = 1; 1717 * 1718 * status = ibt_get_ip_paths(clnt_hdl, flags, &ip_path_attr, &paths, 1719 * &num_paths_p, &src_ip); 1720 * 1721 * sid = ibt_get_ip_sid(protocol_num, dst_port); 1722 * path_info->sid = sid; 1723 * 1724 * ip_cm_info.src_addr = src_ip; 1725 * ip_cm_info.dst_addr = dst_ip_addr; 1726 * ip_cm_info.src_port = src_port 1727 * 1728 * ibt_format_ip_private_data(ip_cm_info, priv_data_len, &priv_data); 1729 * ibt_open_rc_channel(chan, private_data); 1730 */ 1731 typedef struct ibt_ip_path_attr_s { 1732 ibt_ip_addr_t *ipa_dst_ip; /* Required */ 1733 ibt_ip_addr_t ipa_src_ip; /* Optional */ 1734 ib_guid_t ipa_hca_guid; /* Optional */ 1735 uint8_t ipa_hca_port_num; /* Optional */ 1736 uint8_t ipa_max_paths; /* Required */ 1737 uint8_t ipa_ndst; /* Required */ 1738 uint8_t ipa_sl:4; /* Optional */ 1739 ibt_mtu_req_t ipa_mtu; /* Optional */ 1740 ibt_srate_req_t ipa_srate; /* Optional */ 1741 ibt_pkt_lt_req_t ipa_pkt_lt; /* Optional */ 1742 uint_t ipa_flow:20; /* Optional */ 1743 uint8_t ipa_hop; /* Optional */ 1744 uint8_t ipa_tclass; /* Optional */ 1745 } ibt_ip_path_attr_t; 1746 1747 /* 1748 * Path SRC IP addresses 1749 */ 1750 typedef struct ibt_path_ip_src_s { 1751 ibt_ip_addr_t ip_primary; 1752 ibt_ip_addr_t ip_alternate; 1753 } ibt_path_ip_src_t; 1754 1755 1756 ibt_status_t ibt_get_ip_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags, 1757 ibt_ip_path_attr_t *attr, ibt_path_info_t *paths_p, uint8_t *num_paths_p, 1758 ibt_path_ip_src_t *src_ip_p); 1759 1760 ibt_status_t ibt_get_src_ip(ib_gid_t gid, ib_pkey_t pkey, 1761 ibt_ip_addr_t *src_ip); 1762 1763 /* 1764 * Callback function that can be used in ibt_aget_ip_paths(), a Non-Blocking 1765 * version of ibt_get_ip_paths(). 1766 */ 1767 typedef void (*ibt_ip_path_handler_t)(void *arg, ibt_status_t retval, 1768 ibt_path_info_t *paths_p, uint8_t num_paths, ibt_path_ip_src_t *src_ip_p); 1769 1770 /* 1771 * Find path(s) to a given destination or service asynchronously. 1772 * ibt_aget_ip_paths() is a Non-Blocking version of ibt_get_ip_paths(). 1773 */ 1774 ibt_status_t ibt_aget_ip_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags, 1775 ibt_ip_path_attr_t *attr, ibt_ip_path_handler_t func, void *arg); 1776 1777 /* 1778 * IP RDMA protocol functions 1779 */ 1780 1781 /* 1782 * IBTF manages the port number space for non well known ports. If a ULP 1783 * is not using TCP/UDP and a well known port, then ibt_get_ip_sid() returns 1784 * an sid based on the IP protocol number '0' (reserved) and an IBTF assigned 1785 * port number. ibt_release_ip_sid() should be used to release the hold 1786 * of SID created by ibt_get_ip_sid(). 1787 */ 1788 ib_svc_id_t ibt_get_ip_sid(uint8_t protocol_num, in_port_t dst_port); 1789 ibt_status_t ibt_release_ip_sid(ib_svc_id_t sid); 1790 1791 uint8_t ibt_get_ip_protocol_num(ib_svc_id_t sid); 1792 in_port_t ibt_get_ip_dst_port(ib_svc_id_t sid); 1793 1794 /* 1795 * Functions to format/extract the RDMA IP CM private data 1796 */ 1797 typedef struct ibt_ip_cm_info_s { 1798 ibt_ip_addr_t src_addr; 1799 ibt_ip_addr_t dst_addr; 1800 in_port_t src_port; 1801 } ibt_ip_cm_info_t; 1802 1803 /* 1804 * If a ULP is using IP addressing as defined by the RDMA IP CM Service IBTA 1805 * Annex 11, then it must always allocate a private data buffer for use in 1806 * the ibt_open_rc_channel(9F) call. The minimum size of the buffer is 1807 * IBT_IP_HDR_PRIV_DATA_SZ, if the ULP has no ULP specific private data. 1808 * This allows ibt_format_ip_private_data() to place the RDMA IP CM service 1809 * hello message in the private data of the REQ. If the ULP has some ULP 1810 * specific private data then it should allocate a buffer big enough to 1811 * contain that data plus an additional IBT_IP_HDR_PRIV_DATA_SZ bytes. 1812 * The ULP should place its ULP specific private data at offset 1813 * IBT_IP_HDR_PRIV_DATA_SZ in the allocated buffer before calling 1814 * ibt_format_ip_private_data(). 1815 */ 1816 ibt_status_t ibt_format_ip_private_data(ibt_ip_cm_info_t *ip_cm_info, 1817 ibt_priv_data_len_t priv_data_len, void *priv_data_p); 1818 ibt_status_t ibt_get_ip_data(ibt_priv_data_len_t priv_data_len, 1819 void *priv_data, ibt_ip_cm_info_t *ip_info_p); 1820 1821 /* 1822 * The ibt_alt_ip_path_attr_t structure is used to specify additional optional 1823 * attributes when requesting an alternate path for an existing channel. 1824 * 1825 * Attributes that are don't care should be set to NULL or '0'. 1826 */ 1827 typedef struct ibt_alt_ip_path_attr_s { 1828 ibt_ip_addr_t apa_dst_ip; 1829 ibt_ip_addr_t apa_src_ip; 1830 ibt_srate_req_t apa_srate; 1831 ibt_pkt_lt_req_t apa_pkt_lt; /* Packet Life Time Request */ 1832 uint_t apa_flow:20; 1833 uint8_t apa_sl:4; 1834 uint8_t apa_hop; 1835 uint8_t apa_tclass; 1836 } ibt_alt_ip_path_attr_t; 1837 1838 ibt_status_t ibt_get_ip_alt_path(ibt_channel_hdl_t rc_chan, 1839 ibt_path_flags_t flags, ibt_alt_ip_path_attr_t *attr, 1840 ibt_alt_path_info_t *alt_path); 1841 1842 /* 1843 * CONTRACT PRIVATE ONLY INTERFACES 1844 * 1845 * DO NOT USE THE FOLLOWING FUNCTIONS WITHOUT SIGNING THE CONTRACT 1846 * WITH IBTF GROUP. 1847 */ 1848 1849 /* Define an Address Record structure (data for ATS service records). */ 1850 typedef struct ibt_ar_s { 1851 ib_gid_t ar_gid; /* GID of local HCA port */ 1852 ib_pkey_t ar_pkey; /* P_Key valid on port of ar_gid */ 1853 uint8_t ar_data[16]; /* Data affiliated with GID/P_Key */ 1854 } ibt_ar_t; 1855 1856 /* 1857 * ibt_register_ar() 1858 * ibt_deregister_ar() 1859 * Register/deregister an Address Record with the SA. 1860 * ibt_query_ar() 1861 * Query the SA for Address Records matching either GID/P_Key or Data. 1862 */ 1863 ibt_status_t ibt_register_ar(ibt_clnt_hdl_t ibt_hdl, ibt_ar_t *arp); 1864 1865 ibt_status_t ibt_deregister_ar(ibt_clnt_hdl_t ibt_hdl, ibt_ar_t *arp); 1866 1867 ibt_status_t ibt_query_ar(ib_gid_t *sgid, ibt_ar_t *queryp, ibt_ar_t *resultp); 1868 1869 1870 /* 1871 * ibt_modify_system_image() 1872 * ibt_modify_system_image_byguid() 1873 * Modify specified HCA's system image GUID. 1874 */ 1875 ibt_status_t ibt_modify_system_image(ibt_hca_hdl_t hca_hdl, ib_guid_t sys_guid); 1876 1877 ibt_status_t ibt_modify_system_image_byguid(ib_guid_t hca_guid, 1878 ib_guid_t sys_guid); 1879 1880 1881 /* 1882 * ibt_modify_port() 1883 * ibt_modify_port_byguid() 1884 * Modify the specified port, or all ports attribute(s). 1885 */ 1886 ibt_status_t ibt_modify_port(ibt_hca_hdl_t hca_hdl, uint8_t port, 1887 ibt_port_modify_flags_t flags, uint8_t init_type); 1888 1889 ibt_status_t ibt_modify_port_byguid(ib_guid_t hca_guid, uint8_t port, 1890 ibt_port_modify_flags_t flags, uint8_t init_type); 1891 1892 1893 /* 1894 * ibt_get_port_state() 1895 * ibt_get_port_state_byguid() 1896 * Return the most commonly requested attributes of an HCA port. 1897 * If the link state is not IBT_PORT_ACTIVE, the other returned values 1898 * are undefined. 1899 */ 1900 ibt_status_t ibt_get_port_state(ibt_hca_hdl_t hca_hdl, uint8_t port, 1901 ib_gid_t *sgid_p, ib_lid_t *base_lid_p); 1902 1903 ibt_status_t ibt_get_port_state_byguid(ib_guid_t hca_guid, uint8_t port, 1904 ib_gid_t *sgid_p, ib_lid_t *base_lid_p); 1905 1906 #ifdef __cplusplus 1907 } 1908 #endif 1909 1910 #endif /* _SYS_IB_IBTL_IBTI_COMMON_H */ 1911