/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* MODULE: dapl_srq.c
*
* PURPOSE: Shared Receive Queue
* Description: Interfaces in this file are completely described in
* the DAPL 1.2 API, Chapter 6, section 5
*
*/
#include "dapl.h"
#include "dapl_adapter_util.h"
#include "dapl_ia_util.h"
#include "dapl_srq_util.h"
#include "dapl_cookie.h"
/*
* dapl_srq_create
*
* uDAPL: User Direct Access Program Library Version 1.2, 6.5.1
*
* creates an instance of a Shared Receive Queue (SRQ) that is provided
* to the Consumer as srq_handle.
*
* Input:
* ia_handle
* pz_handle
* srq_attr
*
* Output:
* srq_handle
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_HANDLE
* DAT_INVALID_PARAMETER
* DAT_MODEL_NOT_SUPPORTED
*/
{
/*
* Verify parameters
*/
goto bail;
}
goto bail;
}
goto bail;
}
if (srq_handle == NULL) {
goto bail;
}
goto bail;
}
/* Verify the attributes against the transport */
if (dat_status != DAT_SUCCESS) {
goto bail;
}
goto bail;
}
/* Allocate SRQ */
goto bail;
}
/* Take a reference on the PZ handle */
/*
* Fill in the SRQ
*/
if (dat_status != DAT_SUCCESS) {
goto bail;
}
/* Link it onto the IA */
*srq_handle = srq_ptr;
bail:
return (dat_status);
}
/*
* dapl_srq_free
*
* uDAPL: User Direct Access Program Library Version 1.2, 6.5.5
*
* destroys an instance of the SRQ. The SRQ cannot be destroyed if it is
* in use by an EP.
*
* Input:
* srq_handle
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INVALID_HANDLE
* DAT_INVALID_STATE
*/
{
goto bail;
}
if (0 != srq_ptr->srq_ref_count) {
"dapl_srq_free: Free SRQ: %p, refcnt %d\n",
goto bail;
}
/* Remove link from the IA */
bail:
return (dat_status);
}
/*
* dapl_srq_post_recv
*
* uDAPL: User Direct Access Program Library Version 1.2, 6.5.8
*
* posts the receive buffer that can be used for the incoming message into
* the local_iov by any connected EP that uses SRQ.
*
* Input:
* srq_handle
* num_segments
* local_iov
* user_cookie
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INVALID_HANDLE
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
* DAT_PROTECTION_VIOLATION
* DAT_PRIVILEGES_VIOLATION
*/
{
"dapl_srq_post_recv (%p, %d, %p, %P)\n",
goto bail;
}
/*
* Synchronization ok since this buffer is only used for receive
* requests, which aren't allowed to race with each other.
*/
&cookie);
if (DAT_SUCCESS != dat_status) {
goto bail;
}
/*
* Invoke provider specific routine to post DTO
*/
if (dat_status != DAT_SUCCESS) {
} else {
}
bail:
"dapl_srq_post_recv () returns 0x%x\n", dat_status);
return (dat_status);
}
/*
* dapl_srq_query
*
* uDAPL: User Direct Access Program Library Version 1.2, 6.5.6
*
* provides to the Consumer SRQ parameters. The Consumer passes in a pointer
* to the Consumer-allocated structures for SRQ parameters that the Provider
* fills.
*
* Input:
* srq_handle
* srq_param_mask
*
* Output:
* srq_param
*
* Returns:
* DAT_SUCCESS
* DAT_INVALID_HANDLE
* DAT_INVALID_PARAMETER
*/
{
if (srq_param_mask & ~DAT_SRQ_FIELD_ALL) {
goto bail;
}
goto bail;
}
goto bail;
}
/* Do a struct copy */
/* update the outstanding dto count */
bail:
return (dat_status);
}
/*
* dapl_srq_set_lw
*
* uDAPL: User Direct Access Program Library Version 1.2, 6.5.4
*
* sets the low watermark value for SRQ and arms SRQ for generating an
* asynchronous event for low watermark. An asynchronous event will be
* generated when the number of buffers on SRQ is below the low watermark
* for the first time. This may happen during this call or when an
* associated EP takes a buffer from the SRQ.
*
* Input:
* srq_handle
* low_watermark
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INVALID_HANDLE
* DAT_INVALID_PARAMETER
* DAT_MODEL_NOT_SUPPORTED
*/
/* ARGSUSED */
{
return (DAT_MODEL_NOT_SUPPORTED);
}
/*
* dapl_srq_resize
*
* uDAPL: User Direct Access Program Library Version 1.2, 6.5.7
*
* modifies the size of the queue of SRQ. Resizing of SRQ shall not cause
* any incoming messages on any of the EPs that use the SRQ to be lost.
*
* Input:
* srq_handle
* srq_max_recv_dto
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INVALID_HANDLE
* DAT_INVALID_PARAMETER
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_STATE
*/
/* ARGSUSED */
{
}
/* can't shrink below the number of outstanding recvs */
return (DAT_ERROR(DAT_INVALID_STATE, 0));
}
/*
* shrinking SRQs is not supported on tavor return success without
* any modification.
*/
return (DAT_SUCCESS);
}
/* Verify the attributes against the transport */
if (dat_status != DAT_SUCCESS) {
return (dat_status);
}
return (dat_status);
}
&new_cb);
if (dat_status != DAT_SUCCESS) {
return (dat_status);
}
if (dat_status != DAT_SUCCESS) {
goto bail;
}
return (DAT_SUCCESS);
bail:
return (dat_status);
}