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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include <sys/ib/ibtl/impl/ibtl.h> 30 31 /* 32 * ibtl_mem.c 33 * These routines implement all of the Memory Region verbs and the alloc/ 34 * query/free Memory Window verbs at the TI interface. 35 */ 36 37 static char ibtl_mem[] = "ibtl_mem"; 38 39 /* 40 * Function: 41 * ibt_register_mr() 42 * Input: 43 * hca_hdl - HCA Handle. 44 * pd - Protection Domain Handle. 45 * mem_attr - Requested memory region attributes. 46 * Output: 47 * mr_hdl_p - The returned IBT memory region handle. 48 * mem_desc - Returned memory descriptor. 49 * Returns: 50 * IBT_SUCCESS 51 * IBT_CHAN_HDL_INVALID 52 * IBT_MR_VA_INVALID 53 * IBT_MR_LEN_INVALID 54 * IBT_MR_ACCESS_REQ_INVALID 55 * IBT_PD_HDL_INVALID 56 * IBT_INSUFF_RESOURCE 57 * Description: 58 * Prepares a virtually addressed memory region for use by a HCA. A 59 * description of the registered memory suitable for use in Work Requests 60 * (WRs) is returned in the ibt_mr_desc_t parameter. 61 */ 62 ibt_status_t 63 ibt_register_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, ibt_mr_attr_t *mem_attr, 64 ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc) 65 { 66 ib_vaddr_t vaddr; 67 ibt_status_t status; 68 69 IBTF_DPRINTF_L3(ibtl_mem, "ibt_register_mr(%p, %p, %p)", 70 hca_hdl, pd, mem_attr); 71 72 vaddr = mem_attr->mr_vaddr; 73 74 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_register_mr( 75 IBTL_HCA2CIHCA(hca_hdl), pd, mem_attr, IBTL_HCA2CLNT(hca_hdl), 76 mr_hdl_p, mem_desc); 77 if (status == IBT_SUCCESS) { 78 mem_desc->md_vaddr = vaddr; 79 mutex_enter(&hca_hdl->ha_mutex); 80 hca_hdl->ha_mr_cnt++; 81 mutex_exit(&hca_hdl->ha_mutex); 82 } 83 84 return (status); 85 } 86 87 88 /* 89 * Function: 90 * ibt_register_buf() 91 * Input: 92 * hca_hdl HCA Handle. 93 * pd Protection Domain Handle. 94 * mem_bpattr Memory Registration attributes (IOVA and flags). 95 * bp A pointer to a buf(9S) struct. 96 * Output: 97 * mr_hdl_p The returned IBT memory region handle. 98 * mem_desc Returned memory descriptor. 99 * Returns: 100 * IBT_SUCCESS 101 * IBT_CHAN_HDL_INVALID 102 * IBT_MR_VA_INVALID 103 * IBT_MR_LEN_INVALID 104 * IBT_MR_ACCESS_REQ_INVALID 105 * IBT_PD_HDL_INVALID 106 * IBT_INSUFF_RESOURCE 107 * Description: 108 * Prepares a memory region described by a buf(9S) struct for use by a HCA. 109 * A description of the registered memory suitable for use in 110 * Work Requests (WRs) is returned in the ibt_mr_desc_t parameter. 111 */ 112 ibt_status_t 113 ibt_register_buf(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, 114 ibt_smr_attr_t *mem_bpattr, struct buf *bp, ibt_mr_hdl_t *mr_hdl_p, 115 ibt_mr_desc_t *mem_desc) 116 { 117 ibt_status_t status; 118 119 IBTF_DPRINTF_L3(ibtl_mem, "ibt_register_buf(%p, %p, %p, %p)", 120 hca_hdl, pd, mem_bpattr, bp); 121 122 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_register_buf( 123 IBTL_HCA2CIHCA(hca_hdl), pd, mem_bpattr, bp, IBTL_HCA2CLNT(hca_hdl), 124 mr_hdl_p, mem_desc); 125 if (status == IBT_SUCCESS) { 126 mutex_enter(&hca_hdl->ha_mutex); 127 hca_hdl->ha_mr_cnt++; 128 mutex_exit(&hca_hdl->ha_mutex); 129 } 130 131 return (status); 132 } 133 134 135 /* 136 * Function: 137 * ibt_query_mr() 138 * Input: 139 * hca_hdl - HCA Handle. 140 * mr_hdl - The IBT Memory Region handle. 141 * Output: 142 * attr - The pointer to Memory region attributes structure. 143 * Returns: 144 * IBT_SUCCESS 145 * IBT_CHAN_HDL_INVALID 146 * IBT_MR_HDL_INVALID 147 * Description: 148 * Retrieves information about a specified memory region. 149 */ 150 ibt_status_t 151 ibt_query_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 152 ibt_mr_query_attr_t *attr) 153 { 154 IBTF_DPRINTF_L3(ibtl_mem, "ibt_query_mr(%p, %p)", hca_hdl, mr_hdl); 155 156 return (IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_query_mr( 157 IBTL_HCA2CIHCA(hca_hdl), mr_hdl, attr)); 158 } 159 160 161 /* 162 * Function: 163 * ibt_deregister_mr() 164 * Input: 165 * hca_hdl - HCA Handle. 166 * mr_hdl - The IBT Memory Region handle. 167 * Output: 168 * none. 169 * Returns: 170 * IBT_SUCCESS 171 * IBT_CHAN_HDL_INVALID 172 * IBT_MR_HDL_INVALID 173 * IBT_MR_IN_USE 174 * Description: 175 * De-register the registered memory region. Remove a memory region from a 176 * HCA translation table, and free all resources associated with the 177 * memory region. 178 */ 179 ibt_status_t 180 ibt_deregister_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl) 181 { 182 ibt_status_t status; 183 184 IBTF_DPRINTF_L3(ibtl_mem, "ibt_deregister_mr(%p, %p)", hca_hdl, mr_hdl); 185 186 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_deregister_mr( 187 IBTL_HCA2CIHCA(hca_hdl), mr_hdl); 188 if (status == IBT_SUCCESS) { 189 mutex_enter(&hca_hdl->ha_mutex); 190 hca_hdl->ha_mr_cnt--; 191 mutex_exit(&hca_hdl->ha_mutex); 192 } 193 return (status); 194 } 195 196 197 /* 198 * Function: 199 * ibt_reregister_mr() 200 * Input: 201 * hca_hdl - HCA Handle. 202 * mr_hdl - The IBT Memory Region handle. 203 * pd - Optional Protection Domain Handle. 204 * mem_attr - Requested memory region attributes. 205 * Output: 206 * mr_hdl_p - The reregistered IBT memory region handle. 207 * mem_desc - Returned memory descriptor for the new memory region. 208 * Returns: 209 * IBT_SUCCESS 210 * IBT_CHAN_HDL_INVALID 211 * IBT_MR_HDL_INVALID 212 * IBT_MR_VA_INVALID 213 * IBT_MR_LEN_INVALID 214 * IBT_MR_ACCESS_REQ_INVALID 215 * IBT_PD_HDL_INVALID 216 * IBT_INSUFF_RESOURCE 217 * IBT_MR_IN_USE 218 * Description: 219 * Modify the attributes of an existing memory region. 220 */ 221 ibt_status_t 222 ibt_reregister_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, ibt_pd_hdl_t pd, 223 ibt_mr_attr_t *mem_attr, ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc) 224 { 225 ibt_status_t status; 226 ib_vaddr_t vaddr = mem_attr->mr_vaddr; 227 228 IBTF_DPRINTF_L3(ibtl_mem, "ibt_reregister_mr(%p, %p, %p, %p)", 229 hca_hdl, mr_hdl, pd, mem_attr); 230 231 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_reregister_mr( 232 IBTL_HCA2CIHCA(hca_hdl), mr_hdl, pd, mem_attr, 233 IBTL_HCA2CLNT(hca_hdl), mr_hdl_p, mem_desc); 234 235 if (status == IBT_SUCCESS) 236 mem_desc->md_vaddr = vaddr; 237 else if (!(status == IBT_MR_IN_USE || status == IBT_HCA_HDL_INVALID || 238 status == IBT_MR_HDL_INVALID)) { 239 240 IBTF_DPRINTF_L2(ibtl_mem, "ibt_reregister_mr: " 241 "Re-registration Failed: %d", status); 242 243 /* we lost one memory region resource */ 244 mutex_enter(&hca_hdl->ha_mutex); 245 hca_hdl->ha_mr_cnt--; 246 mutex_exit(&hca_hdl->ha_mutex); 247 } 248 249 return (status); 250 } 251 252 253 /* 254 * Function: 255 * ibt_reregister_buf() 256 * Input: 257 * hca_hdl HCA Handle. 258 * mr_hdl The IBT Memory Region handle. 259 * pd Optional Protection Domain Handle. 260 * mem_bpattr Memory Registration attributes (IOVA and flags). 261 * bp A pointer to a buf(9S) struct. 262 * Output: 263 * mr_hdl_p The reregistered IBT memory region handle. 264 * mem_desc Returned memory descriptor for the new memory region. 265 * Returns: 266 * IBT_SUCCESS 267 * IBT_CHAN_HDL_INVALID 268 * IBT_MR_HDL_INVALID 269 * IBT_MR_VA_INVALID 270 * IBT_MR_LEN_INVALID 271 * IBT_MR_ACCESS_REQ_INVALID 272 * IBT_PD_HDL_INVALID 273 * IBT_INSUFF_RESOURCE 274 * IBT_MR_IN_USE 275 * Description: 276 * Modify the attributes of an existing memory region as described by a 277 * buf(9S) struct for use by a HCA. A description of the registered 278 * memory suitable for use in Work Requests (WRs) is returned in the 279 * ibt_mr_desc_t parameter. 280 */ 281 ibt_status_t 282 ibt_reregister_buf(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 283 ibt_pd_hdl_t pd, ibt_smr_attr_t *mem_bpattr, struct buf *bp, 284 ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc) 285 { 286 ibt_status_t status; 287 288 IBTF_DPRINTF_L3(ibtl_mem, "ibt_reregister_buf(%p, %p, %p, %p, %p)", 289 hca_hdl, mr_hdl, pd, mem_bpattr, bp); 290 291 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_reregister_buf( 292 IBTL_HCA2CIHCA(hca_hdl), mr_hdl, pd, mem_bpattr, bp, 293 IBTL_HCA2CLNT(hca_hdl), mr_hdl_p, mem_desc); 294 295 if (!(status == IBT_SUCCESS || status == IBT_MR_IN_USE || 296 status == IBT_HCA_HDL_INVALID || status == IBT_MR_HDL_INVALID)) { 297 298 IBTF_DPRINTF_L2(ibtl_mem, "ibt_reregister_buf: " 299 "Re-registration Mem Failed: %d", status); 300 301 /* we lost one memory region resource */ 302 mutex_enter(&hca_hdl->ha_mutex); 303 hca_hdl->ha_mr_cnt--; 304 mutex_exit(&hca_hdl->ha_mutex); 305 } 306 return (status); 307 } 308 309 310 /* 311 * Function: 312 * ibt_register_shared_mr() 313 * Input: 314 * hca_hdl - HCA Handle. 315 * mr_hdl - The IBT Memory Region handle. 316 * pd - Protection Domain Handle. 317 * mem_sattr - Requested memory region shared attributes. 318 * Output: 319 * mr_hdl_p - The reregistered IBT memory region handle. 320 * mem_desc - Returned memory descriptor for the new memory region. 321 * Returns: 322 * IBT_SUCCESS 323 * IBT_INSUFF_RESOURCE 324 * IBT_CHAN_HDL_INVALID 325 * IBT_MR_HDL_INVALID 326 * IBT_PD_HDL_INVALID 327 * IBT_MR_ACCESS_REQ_INVALID 328 * Description: 329 * Given an existing memory region, a new memory region associated with 330 * the same physical locations is created. 331 */ 332 ibt_status_t 333 ibt_register_shared_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 334 ibt_pd_hdl_t pd, ibt_smr_attr_t *mem_sattr, ibt_mr_hdl_t *mr_hdl_p, 335 ibt_mr_desc_t *mem_desc) 336 { 337 ibt_status_t status; 338 339 IBTF_DPRINTF_L3(ibtl_mem, "ibt_register_shared_mr(%p, %p, %p, %p)", 340 hca_hdl, mr_hdl, pd, mem_sattr); 341 342 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_register_shared_mr( 343 IBTL_HCA2CIHCA(hca_hdl), mr_hdl, pd, mem_sattr, 344 IBTL_HCA2CLNT(hca_hdl), mr_hdl_p, mem_desc); 345 if (status == IBT_SUCCESS) { 346 mutex_enter(&hca_hdl->ha_mutex); 347 hca_hdl->ha_mr_cnt++; 348 mutex_exit(&hca_hdl->ha_mutex); 349 } 350 return (status); 351 } 352 353 /* 354 * Function: 355 * ibt_sync_mr() 356 * Input: 357 * hca_hdl - HCA Handle. 358 * mr_segments - A pointer to an array of ibt_mr_sync_t that describes 359 * the memory regions to sync. 360 * num_segments - The length of the mr_segments array. 361 * Output: 362 * NONE 363 * Returns: 364 * IBT_SUCCESS 365 * IBT_HCA_HDL_INVALID 366 * IBT_MR_HDL_INVALID 367 * IBT_INVALID_PARAM 368 * IBT_MR_VA_INVALID 369 * IBT_MR_LEN_INVALID 370 * Description: 371 * Make memory changes visible to incoming RDMA reads, or make the affects 372 * of an incoming RDMA writes visible to the consumer. 373 */ 374 ibt_status_t 375 ibt_sync_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_sync_t *mr_segments, 376 size_t num_segments) 377 378 { 379 IBTF_DPRINTF_L3(ibtl_mem, "ibt_sync_mr(%p, %p, %d)", hca_hdl, 380 mr_segments, num_segments); 381 382 return (IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_sync_mr( 383 IBTL_HCA2CIHCA(hca_hdl), mr_segments, num_segments)); 384 } 385 386 387 /* 388 * Function: 389 * ibt_alloc_mw() 390 * Input: 391 * hca_hdl - HCA Handle. 392 * pd - Protection Domain Handle. 393 * flags - Memory Window alloc flags. 394 * Output: 395 * mw_hdl_p - The returned IBT Memory Window handle. 396 * rkey - The IBT R_Key handle. 397 * Returns: 398 * IBT_SUCCESS 399 * IBT_INSUFF_RESOURCE 400 * IBT_CHAN_HDL_INVALID 401 * IBT_PD_HDL_INVALID 402 * Description: 403 * Allocate a memory window from the HCA. 404 */ 405 ibt_status_t 406 ibt_alloc_mw(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, ibt_mw_flags_t flags, 407 ibt_mw_hdl_t *mw_hdl_p, ibt_rkey_t *rkey) 408 { 409 ibt_status_t status; 410 411 IBTF_DPRINTF_L3(ibtl_mem, "ibt_alloc_mw(%p, %p, 0x%x)", 412 hca_hdl, pd, flags); 413 414 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_alloc_mw( 415 IBTL_HCA2CIHCA(hca_hdl), pd, flags, mw_hdl_p, rkey); 416 417 /* 418 * XXX - We should be able to allocate state and have a IBTF Memory 419 * Window Handle. Memory Windows are meant to be rebound on the fly 420 * (using a post) to make them fast. It is expected that alloc memory 421 * window will be done in a relatively static manner. But, we don't have 422 * a good reason to have local MW state at this point, so we won't. 423 */ 424 if (status == IBT_SUCCESS) { 425 mutex_enter(&hca_hdl->ha_mutex); 426 hca_hdl->ha_mw_cnt++; 427 mutex_exit(&hca_hdl->ha_mutex); 428 } 429 return (status); 430 } 431 432 433 /* 434 * Function: 435 * ibt_query_mw() 436 * Input: 437 * hca_hdl - HCA Handle. 438 * mw_hdl - The IBT Memory Window handle. 439 * Output: 440 * pd - Protection Domain Handle. 441 * rkey - The IBT R_Key handle. 442 * Returns: 443 * IBT_SUCCESS 444 * IBT_CHAN_HDL_INVALID 445 * IBT_MW_HDL_INVALID 446 * Description: 447 * Retrieves information about a specified memory region. 448 */ 449 ibt_status_t 450 ibt_query_mw(ibt_hca_hdl_t hca_hdl, ibt_mw_hdl_t mw_hdl, 451 ibt_mw_query_attr_t *mw_attr_p) 452 { 453 IBTF_DPRINTF_L3(ibtl_mem, "ibt_query_mw(%p, %p)", hca_hdl, mw_hdl); 454 455 return (IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_query_mw( 456 IBTL_HCA2CIHCA(hca_hdl), mw_hdl, mw_attr_p)); 457 } 458 459 460 /* 461 * Function: 462 * ibt_free_mw() 463 * Input: 464 * hca_hdl - HCA Handle 465 * mw_hdl - The IBT Memory Window handle. 466 * Output: 467 * none. 468 * Returns: 469 * IBT_SUCCESS 470 * IBT_CHAN_HDL_INVALID 471 * IBT_MW_HDL_INVALID 472 * Description: 473 * De-allocate the Memory Window. 474 */ 475 ibt_status_t 476 ibt_free_mw(ibt_hca_hdl_t hca_hdl, ibt_mw_hdl_t mw_hdl) 477 { 478 ibt_status_t status; 479 480 IBTF_DPRINTF_L3(ibtl_mem, "ibt_free_mw(%p, %p)", hca_hdl, mw_hdl); 481 482 status = IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_free_mw( 483 IBTL_HCA2CIHCA(hca_hdl), mw_hdl); 484 485 if (status == IBT_SUCCESS) { 486 mutex_enter(&hca_hdl->ha_mutex); 487 hca_hdl->ha_mw_cnt--; 488 mutex_exit(&hca_hdl->ha_mutex); 489 } 490 return (status); 491 } 492 493 494 /* 495 * Function: 496 * ibt_map_mem_area() 497 * Input: 498 * hca_hdl HCA Handle 499 * va_attrs A pointer to an ibt_va_attr_t that describes the 500 * VA to be translated. 501 * paddr_list_len The number of entries in the 'paddr_list_p' array. 502 * Output: 503 * paddr_list_p Array of ibt_phys_buf_t (allocated by the caller), 504 * in which the physical buffers that map the virtual 505 * buffer are returned. 506 * num_paddr_p The actual number of ibt_phys_buf_t that were 507 * returned in the 'paddr_list_p' array. 508 * ma_hdl_p Memory Area Handle. 509 * Returns: 510 * IBT_SUCCESS 511 * Description: 512 * Translate a kernel virtual address range into HCA physical addresses. 513 * A set of physical addresses, that can be used with "Reserved L_Key", 514 * register physical, and "Fast Registration Work Request" operations 515 * is returned. 516 */ 517 ibt_status_t 518 ibt_map_mem_area(ibt_hca_hdl_t hca_hdl, ibt_va_attr_t *va_attrs, 519 uint_t paddr_list_len, ibt_phys_buf_t *paddr_list_p, uint_t *num_paddr_p, 520 ibt_ma_hdl_t *ma_hdl_p) 521 { 522 IBTF_DPRINTF_L3(ibtl_mem, "ibt_map_mem_area(%p, %p, %d)", 523 hca_hdl, va_attrs, paddr_list_len); 524 525 return (IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_map_mem_area( 526 IBTL_HCA2CIHCA(hca_hdl), va_attrs, 527 NULL, /* IBTL_HCA2MODI_P(hca_hdl)->mi_reserved */ 528 paddr_list_len, paddr_list_p, 529 num_paddr_p, ma_hdl_p)); 530 } 531 532 533 /* 534 * Function: 535 * ibt_unmap_mem_area() 536 * Input: 537 * hca_hdl HCA Handle 538 * ma_hdl Memory Area Handle. 539 * Output: 540 * None. 541 * Returns: 542 * IBT_SUCCESS 543 * Description: 544 * Un pin physical pages pinned during an ibt_map_mem_area() call. 545 */ 546 ibt_status_t 547 ibt_unmap_mem_area(ibt_hca_hdl_t hca_hdl, ibt_ma_hdl_t ma_hdl) 548 { 549 IBTF_DPRINTF_L3(ibtl_mem, "ibt_unmap_mem_area(%p, %p)", 550 hca_hdl, ma_hdl); 551 552 return (IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_unmap_mem_area( 553 IBTL_HCA2CIHCA(hca_hdl), ma_hdl)); 554 } 555 556 557 /* 558 * Function: 559 * ibt_alloc_lkey() 560 * Input: 561 * hca_hdl HCA Handle 562 * pd A protection domain handle. 563 * flags Access control. 564 * phys_buf_list_sz Requested size of Physical Buffer List (PBL) 565 * resources to be allocated. 566 * Output: 567 * mr_hdl_p The returned IBT memory region handle. 568 * mem_desc_p Returned memory descriptor. 569 * Returns: 570 * IBT_SUCCESS 571 * Description: 572 * Allocates physical buffer list resources for use in memory 573 * registrations. 574 */ 575 ibt_status_t 576 ibt_alloc_lkey(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, ibt_lkey_flags_t flags, 577 uint_t phys_buf_list_sz, ibt_mr_hdl_t *mr_hdl_p, 578 ibt_pmr_desc_t *mem_desc_p) 579 { 580 IBTF_DPRINTF_L3(ibtl_mem, "ibt_alloc_lkey(%p, %p, 0x%X, %d)", 581 hca_hdl, pd, flags, phys_buf_list_sz); 582 583 return (IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_alloc_lkey( 584 IBTL_HCA2CIHCA(hca_hdl), pd, flags, phys_buf_list_sz, mr_hdl_p, 585 mem_desc_p)); 586 } 587 588 589 /* 590 * Function: 591 * ibt_register_phys_mr() 592 * Input: 593 * hca_hdl HCA Handle 594 * pd A protection domain handle. 595 * mem_pattr Requested memory region physical attributes. 596 * Output: 597 * mr_hdl_p The returned IBT memory region handle. 598 * mem_desc_p Returned memory descriptor. 599 * Returns: 600 * IBT_SUCCESS 601 * Description: 602 * Prepares a physically addressed memory region for use by a HCA. 603 */ 604 ibt_status_t 605 ibt_register_phys_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd, 606 ibt_pmr_attr_t *mem_pattr, ibt_mr_hdl_t *mr_hdl_p, 607 ibt_pmr_desc_t *mem_desc_p) 608 { 609 IBTF_DPRINTF_L3(ibtl_mem, "ibt_register_phys_mr(%p, %p, %p)", 610 hca_hdl, pd, mem_pattr); 611 612 return (IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_register_physical_mr( 613 IBTL_HCA2CIHCA(hca_hdl), pd, mem_pattr, 614 NULL, /* IBTL_HCA2MODI_P(hca_hdl)->mi_reserved */ 615 mr_hdl_p, mem_desc_p)); 616 } 617 618 619 /* 620 * Function: 621 * ibt_reregister_phys_mr() 622 * Input: 623 * hca_hdl HCA Handle 624 * mr_hdl The IBT memory region handle. 625 * pd A protection domain handle. 626 * mem_pattr Requested memory region physical attributes. 627 * Output: 628 * mr_hdl_p The returned IBT memory region handle. 629 * mem_desc_p Returned memory descriptor. 630 * Returns: 631 * IBT_SUCCESS 632 * Description: 633 * Prepares a physically addressed memory region for use by a HCA. 634 */ 635 ibt_status_t 636 ibt_reregister_phys_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl, 637 ibt_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr, ibt_mr_hdl_t *mr_hdl_p, 638 ibt_pmr_desc_t *mem_desc_p) 639 { 640 IBTF_DPRINTF_L3(ibtl_mem, "ibt_reregister_phys_mr(%p, %p, %p, %p)", 641 hca_hdl, mr_hdl, pd, mem_pattr); 642 643 return (IBTL_HCA2CIHCAOPS_P(hca_hdl)->ibc_reregister_physical_mr( 644 IBTL_HCA2CIHCA(hca_hdl), mr_hdl, pd, mem_pattr, 645 NULL, /* IBTL_HCA2MODI_P(hca_hdl)->mi_reserved */ 646 mr_hdl_p, mem_desc_p)); 647 } 648