ibtl_mem.c revision 43ed929a6988c3778f00123f4a4a8541e515ec16
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* These routines implement all of the Memory Region verbs and the alloc/
*/
static char ibtl_mem[] = "ibtl_mem";
/*
* Function:
* ibt_register_mr()
* Input:
* hca_hdl - HCA Handle.
* pd - Protection Domain Handle.
* mem_attr - Requested memory region attributes.
* Output:
* mr_hdl_p - The returned IBT memory region handle.
* mem_desc - Returned memory descriptor.
* Returns:
* IBT_SUCCESS
* IBT_CHAN_HDL_INVALID
* IBT_MR_VA_INVALID
* IBT_MR_LEN_INVALID
* IBT_MR_ACCESS_REQ_INVALID
* IBT_PD_HDL_INVALID
* IBT_INSUFF_RESOURCE
* Description:
* Prepares a virtually addressed memory region for use by a HCA. A
* description of the registered memory suitable for use in Work Requests
* (WRs) is returned in the ibt_mr_desc_t parameter.
*/
{
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_register_buf()
* Input:
* hca_hdl HCA Handle.
* pd Protection Domain Handle.
* mem_bpattr Memory Registration attributes (IOVA and flags).
* bp A pointer to a buf(9S) struct.
* Output:
* mr_hdl_p The returned IBT memory region handle.
* mem_desc Returned memory descriptor.
* Returns:
* IBT_SUCCESS
* IBT_CHAN_HDL_INVALID
* IBT_MR_VA_INVALID
* IBT_MR_LEN_INVALID
* IBT_MR_ACCESS_REQ_INVALID
* IBT_PD_HDL_INVALID
* IBT_INSUFF_RESOURCE
* Description:
* Prepares a memory region described by a buf(9S) struct for use by a HCA.
* A description of the registered memory suitable for use in
* Work Requests (WRs) is returned in the ibt_mr_desc_t parameter.
*/
{
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_query_mr()
* Input:
* hca_hdl - HCA Handle.
* mr_hdl - The IBT Memory Region handle.
* Output:
* attr - The pointer to Memory region attributes structure.
* Returns:
* IBT_SUCCESS
* IBT_CHAN_HDL_INVALID
* IBT_MR_HDL_INVALID
* Description:
* Retrieves information about a specified memory region.
*/
{
}
/*
* Function:
* ibt_deregister_mr()
* Input:
* hca_hdl - HCA Handle.
* mr_hdl - The IBT Memory Region handle.
* Output:
* none.
* Returns:
* IBT_SUCCESS
* IBT_CHAN_HDL_INVALID
* IBT_MR_HDL_INVALID
* IBT_MR_IN_USE
* Description:
* De-register the registered memory region. Remove a memory region from a
* HCA translation table, and free all resources associated with the
* memory region.
*/
{
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_reregister_mr()
* Input:
* hca_hdl - HCA Handle.
* mr_hdl - The IBT Memory Region handle.
* pd - Optional Protection Domain Handle.
* mem_attr - Requested memory region attributes.
* Output:
* mr_hdl_p - The reregistered IBT memory region handle.
* mem_desc - Returned memory descriptor for the new memory region.
* Returns:
* IBT_SUCCESS
* IBT_CHAN_HDL_INVALID
* IBT_MR_HDL_INVALID
* IBT_MR_VA_INVALID
* IBT_MR_LEN_INVALID
* IBT_MR_ACCESS_REQ_INVALID
* IBT_PD_HDL_INVALID
* IBT_INSUFF_RESOURCE
* IBT_MR_IN_USE
* Description:
* Modify the attributes of an existing memory region.
*/
{
if (status == IBT_SUCCESS)
status == IBT_MR_HDL_INVALID)) {
"Re-registration Failed: %d", status);
/* we lost one memory region resource */
}
return (status);
}
/*
* Function:
* ibt_reregister_buf()
* Input:
* hca_hdl HCA Handle.
* mr_hdl The IBT Memory Region handle.
* pd Optional Protection Domain Handle.
* mem_bpattr Memory Registration attributes (IOVA and flags).
* bp A pointer to a buf(9S) struct.
* Output:
* mr_hdl_p The reregistered IBT memory region handle.
* mem_desc Returned memory descriptor for the new memory region.
* Returns:
* IBT_SUCCESS
* IBT_CHAN_HDL_INVALID
* IBT_MR_HDL_INVALID
* IBT_MR_VA_INVALID
* IBT_MR_LEN_INVALID
* IBT_MR_ACCESS_REQ_INVALID
* IBT_PD_HDL_INVALID
* IBT_INSUFF_RESOURCE
* IBT_MR_IN_USE
* Description:
* Modify the attributes of an existing memory region as described by a
* buf(9S) struct for use by a HCA. A description of the registered
* memory suitable for use in Work Requests (WRs) is returned in the
* ibt_mr_desc_t parameter.
*/
{
"Re-registration Mem Failed: %d", status);
/* we lost one memory region resource */
}
return (status);
}
/*
* Function:
* ibt_register_shared_mr()
* Input:
* hca_hdl - HCA Handle.
* mr_hdl - The IBT Memory Region handle.
* pd - Protection Domain Handle.
* mem_sattr - Requested memory region shared attributes.
* Output:
* mr_hdl_p - The reregistered IBT memory region handle.
* mem_desc - Returned memory descriptor for the new memory region.
* Returns:
* IBT_SUCCESS
* IBT_INSUFF_RESOURCE
* IBT_CHAN_HDL_INVALID
* IBT_MR_HDL_INVALID
* IBT_PD_HDL_INVALID
* IBT_MR_ACCESS_REQ_INVALID
* Description:
* Given an existing memory region, a new memory region associated with
* the same physical locations is created.
*/
{
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_sync_mr()
* Input:
* hca_hdl - HCA Handle.
* mr_segments - A pointer to an array of ibt_mr_sync_t that describes
* the memory regions to sync.
* num_segments - The length of the mr_segments array.
* Output:
* NONE
* Returns:
* IBT_SUCCESS
* IBT_HCA_HDL_INVALID
* IBT_MR_HDL_INVALID
* IBT_INVALID_PARAM
* IBT_MR_VA_INVALID
* IBT_MR_LEN_INVALID
* Description:
* Make memory changes visible to incoming RDMA reads, or make the affects
* of an incoming RDMA writes visible to the consumer.
*/
{
}
/*
* Function:
* ibt_alloc_mw()
* Input:
* hca_hdl - HCA Handle.
* pd - Protection Domain Handle.
* flags - Memory Window alloc flags.
* Output:
* mw_hdl_p - The returned IBT Memory Window handle.
* rkey - The IBT R_Key handle.
* Returns:
* IBT_SUCCESS
* IBT_INSUFF_RESOURCE
* IBT_CHAN_HDL_INVALID
* IBT_PD_HDL_INVALID
* Description:
* Allocate a memory window from the HCA.
*/
{
/*
* XXX - We should be able to allocate state and have a IBTF Memory
* Window Handle. Memory Windows are meant to be rebound on the fly
* (using a post) to make them fast. It is expected that alloc memory
* window will be done in a relatively static manner. But, we don't have
* a good reason to have local MW state at this point, so we won't.
*/
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_query_mw()
* Input:
* hca_hdl - HCA Handle.
* mw_hdl - The IBT Memory Window handle.
* Output:
* pd - Protection Domain Handle.
* rkey - The IBT R_Key handle.
* Returns:
* IBT_SUCCESS
* IBT_CHAN_HDL_INVALID
* IBT_MW_HDL_INVALID
* Description:
* Retrieves information about a specified memory region.
*/
{
}
/*
* Function:
* ibt_free_mw()
* Input:
* hca_hdl - HCA Handle
* mw_hdl - The IBT Memory Window handle.
* Output:
* none.
* Returns:
* IBT_SUCCESS
* IBT_CHAN_HDL_INVALID
* IBT_MW_HDL_INVALID
* Description:
* De-allocate the Memory Window.
*/
{
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_map_mem_area()
* Input:
* hca_hdl HCA Handle
* va_attrs A pointer to an ibt_va_attr_t that describes the
* VA to be translated.
* paddr_list_len The number of entries in the 'paddr_list_p' array.
* Output:
* paddr_list_p Array of ibt_phys_buf_t (allocated by the caller),
* in which the physical buffers that map the virtual
* buffer are returned.
* num_paddr_p The actual number of ibt_phys_buf_t that were
* returned in the 'paddr_list_p' array.
* ma_hdl_p Memory Area Handle.
* Returns:
* IBT_SUCCESS
* Description:
* Translate a kernel virtual address range into HCA physical addresses.
* A set of physical addresses, that can be used with "Reserved L_Key",
* register physical, and "Fast Registration Work Request" operations
* is returned.
*/
{
NULL, /* IBTL_HCA2MODI_P(hca_hdl)->mi_reserved */
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_unmap_mem_area()
* Input:
* hca_hdl HCA Handle
* ma_hdl Memory Area Handle.
* Output:
* None.
* Returns:
* IBT_SUCCESS
* Description:
* Un pin physical pages pinned during an ibt_map_mem_area() call.
*/
{
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_alloc_lkey()
* Input:
* hca_hdl HCA Handle
* pd A protection domain handle.
* flags Access control.
* phys_buf_list_sz Requested size of Physical Buffer List (PBL)
* resources to be allocated.
* Output:
* mr_hdl_p The returned IBT memory region handle.
* mem_desc_p Returned memory descriptor.
* Returns:
* IBT_SUCCESS
* Description:
* Allocates physical buffer list resources for use in memory
* registrations.
*/
{
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_register_phys_mr()
* Input:
* hca_hdl HCA Handle
* pd A protection domain handle.
* mem_pattr Requested memory region physical attributes.
* Output:
* mr_hdl_p The returned IBT memory region handle.
* mem_desc_p Returned memory descriptor.
* Returns:
* IBT_SUCCESS
* Description:
* Prepares a physically addressed memory region for use by a HCA.
*/
{
NULL, /* IBTL_HCA2MODI_P(hca_hdl)->mi_reserved */
if (status == IBT_SUCCESS) {
}
return (status);
}
/*
* Function:
* ibt_reregister_phys_mr()
* Input:
* hca_hdl HCA Handle
* mr_hdl The IBT memory region handle.
* pd A protection domain handle.
* mem_pattr Requested memory region physical attributes.
* Output:
* mr_hdl_p The returned IBT memory region handle.
* mem_desc_p Returned memory descriptor.
* Returns:
* IBT_SUCCESS
* Description:
* Prepares a physically addressed memory region for use by a HCA.
*/
{
NULL, /* IBTL_HCA2MODI_P(hca_hdl)->mi_reserved */
"Re-registration Mem Failed: %d", status);
/* we lost one memory region resource */
}
return (status);
}
/*
* Fast Memory Registration (FMR).
*
* ibt_create_fmr_pool
* Not fast-path.
* ibt_create_fmr_pool() verifies that the HCA supports FMR and allocates
* and initializes an "FMR pool". This pool contains state specific to
* this registration, including the watermark setting to determine when
* to sync, and the total number of FMR regions available within this pool.
*
*/
{
if (status != IBT_SUCCESS) {
*fmr_pool_p = NULL;
return (status);
}
/* Update the FMR resource count */
return (status);
}
/*
* ibt_destroy_fmr_pool
* ibt_destroy_fmr_pool() deallocates all of the FMR regions in a specific
* pool. All state and information regarding the pool are destroyed and
* returned as free space once again. No more use of FMR regions in this
* pool are possible without a subsequent call to ibt_create_fmr_pool().
*/
{
if (status != IBT_SUCCESS) {
"CI FMR Pool destroy failed (%d)", status);
return (status);
}
return (status);
}
/*
* ibt_flush_fmr_pool
* ibt_flush_fmr_pool forces a flush to occur. At the client's request,
* any unmapped FMR regions (See 'ibt_deregister_mr())') are returned to
* a free state. This function allows for an asynchronous cleanup of
* formerly used FMR regions. Sync operation is also performed internally
* by HCA driver, when 'watermark' settings for the number of free FMR
* regions left in the "pool" is reached.
*/
{
}
/*
* ibt_register_physical_fmr
* ibt_register_physical_fmr() assigns a "free" entry from the FMR Pool.
* It first consults the "FMR cache" to see if this is a duplicate memory
* registration to something already in use. If not, then a free entry
* in the "pool" is marked used.
*/
{
NULL, /* IBTL_HCA2MODI_P(hca_hdl)->mi_reserved */
mr_hdl_p, mem_desc_p));
}
/*
* ibt_deregister_fmr
* The ibt_deregister_fmr un-maps the resources reserved from the FMR
* pool by ibt_register_physical_fmr(). The ibt_deregister_fmr() will
* mark the region as free in the FMR Pool.
*/
{
}