Blame IbAccess/Common/Public/ireqmgr.h

Packit 857059
/* BEGIN_ICS_COPYRIGHT3 ****************************************
Packit 857059
Packit 857059
Copyright (c) 2015, Intel Corporation
Packit 857059
Packit 857059
Redistribution and use in source and binary forms, with or without
Packit 857059
modification, are permitted provided that the following conditions are met:
Packit 857059
Packit 857059
    * Redistributions of source code must retain the above copyright notice,
Packit 857059
      this list of conditions and the following disclaimer.
Packit 857059
    * Redistributions in binary form must reproduce the above copyright
Packit 857059
      notice, this list of conditions and the following disclaimer in the
Packit 857059
     documentation and/or other materials provided with the distribution.
Packit 857059
    * Neither the name of Intel Corporation nor the names of its contributors
Packit 857059
      may be used to endorse or promote products derived from this software
Packit 857059
      without specific prior written permission.
Packit 857059
Packit 857059
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 857059
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 857059
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit 857059
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit 857059
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 857059
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit 857059
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit 857059
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit 857059
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 857059
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 857059
Packit 857059
** END_ICS_COPYRIGHT3   ****************************************/
Packit 857059
Packit 857059
/* [ICS VERSION STRING: unknown] */
Packit 857059
Packit 857059
Packit 857059
#ifndef _IBA_PUBLIC_IREQ_MGR_H_
Packit 857059
#define _IBA_PUBLIC_IREQ_MGR_H_
Packit 857059
Packit 857059
#include "iba/public/datatypes.h"
Packit 857059
#include "iba/public/igrowpool.h"
Packit 857059
#include "iba/public/ilist.h"
Packit 857059
Packit 857059
#ifdef __cplusplus
Packit 857059
extern "C" {
Packit 857059
#endif
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * Generic request callback type, used to queue requests.
Packit 857059
 *
Packit 857059
 ****************************************************************************/
Packit 857059
typedef void 
Packit 857059
(*REQ_CALLBACK)( void );
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * This structure is used to manage queuing requests for objects.
Packit 857059
 *
Packit 857059
 ****************************************************************************/
Packit 857059
typedef struct _REQUEST_OBJECT
Packit 857059
{
Packit 857059
	uint32			Count;			/* Number of items requested. */
Packit 857059
	boolean			PartialOk;		/* Is it okay to return some of the items. */
Packit 857059
	REQ_CALLBACK	pfnCallback;	/* Notification routine when completed. */
Packit 857059
	void			*Context1;		/* Callback context information. */
Packit 857059
	void			*Context2;		/* Callback context information. */
Packit 857059
Packit 857059
} REQUEST_OBJECT;
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * The REQ_MGR_GET_TYPE enumarated type is used to specify the type of 
Packit 857059
 * request being performed when calling ReqMgrGet().
Packit 857059
 *
Packit 857059
 ****************************************************************************/
Packit 857059
typedef enum _REQ_MGR_TYPE
Packit 857059
{
Packit 857059
	ReqGetSync,
Packit 857059
	ReqGetAsync,
Packit 857059
	ReqGetAsyncPartialOk
Packit 857059
Packit 857059
} REQ_MGR_TYPE;
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * GET_AVAILABLE_COUNT
Packit 857059
 *
Packit 857059
 * Description:
Packit 857059
 *	Function type declaration for the object count callback function invoked by
Packit 857059
 *	the request manager to retrieve the number of objects available.
Packit 857059
 *
Packit 857059
 * Inputs:
Packit 857059
 *	Context - User specified context.
Packit 857059
 *
Packit 857059
 * Outputs:
Packit 857059
 *	None.
Packit 857059
 *
Packit 857059
 * Returns:
Packit 857059
 *	Number of available objects.
Packit 857059
 *
Packit 857059
 ****************************************************************************/
Packit 857059
typedef uint32 (*REQMGR_GET_COUNT_FUNC)(
Packit 857059
	IN void *Context );
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * REQ_MGR object.
Packit 857059
 *
Packit 857059
 ****************************************************************************/
Packit 857059
typedef struct _REQ_MGR
Packit 857059
{
Packit 857059
	/* Pointer to the count callback function. */
Packit 857059
	REQMGR_GET_COUNT_FUNC	m_pfnGetCount;		/* DO NOT USE!! */
Packit 857059
	/* Context to pass as single parameter to count callback. */
Packit 857059
	void					*m_GetContext;		/* DO NOT USE!! */
Packit 857059
Packit 857059
	/* Offset into each object where the chain pointers are located. */
Packit 857059
	uint32					m_NextPtrOffset;	/* DO NOT USE!! */
Packit 857059
	uint32					m_PrevPtrOffset;	/* DO NOT USE!! */
Packit 857059
Packit 857059
	/* Pending requests for elements. */
Packit 857059
	QUEUE					m_RequestQueue;		/* DO NOT USE!! */
Packit 857059
Packit 857059
	/* Requests are dynamically allocated and added to the stack. */
Packit 857059
	GROW_POOL				m_RequestPool;		/* DO NOT USE!! */
Packit 857059
Packit 857059
	boolean					m_Initialized;		/* DO NOT USE!! */
Packit 857059
Packit 857059
} REQ_MGR;
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * ReqMgrInitState
Packit 857059
 * 
Packit 857059
 * Description:
Packit 857059
 *	This function performs basic request manager initialization.  This 
Packit 857059
 *	function cannot fail.
Packit 857059
 * 
Packit 857059
 * Inputs:
Packit 857059
 *	pReqMgr - Pointer to a request manager structure.
Packit 857059
 * 
Packit 857059
 * Outputs:
Packit 857059
 *	None.
Packit 857059
 * 
Packit 857059
 * Returns:
Packit 857059
 *	None.
Packit 857059
 * 
Packit 857059
 ****************************************************************************/
Packit 857059
void
Packit 857059
ReqMgrInitState(
Packit 857059
	IN REQ_MGR* const pReqMgr );
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * ReqMgrInit
Packit 857059
 * 
Packit 857059
 * Description:
Packit 857059
 *	Initializes the request manager for use.
Packit 857059
 * 
Packit 857059
 * Inputs:
Packit 857059
 *	pReqMgr			- Pointer to a request manager.
Packit 857059
 *	pfnGetCount		- Pointer to a callback function invoked to 
Packit 857059
 *					get the number of available objects.
Packit 857059
 *	GetContext		- Context to pass into the pfnGetCount function.
Packit 857059
 *
Packit 857059
 * Outputs:
Packit 857059
 *	None.
Packit 857059
 * 
Packit 857059
 * Returns:
Packit 857059
 *	FSUCCESS				- the request manager was successfully initialized.
Packit 857059
 *	FINSUFFICIENT_MEMORY	- there was not enough memory to initialize the
Packit 857059
 *							request manager.
Packit 857059
 * 
Packit 857059
 ****************************************************************************/
Packit 857059
FSTATUS
Packit 857059
ReqMgrInit(
Packit 857059
	IN REQ_MGR* const pReqMgr,
Packit 857059
	IN REQMGR_GET_COUNT_FUNC pfnGetCount,
Packit 857059
	IN void* const GetContext );
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * ReqMgrDestroy
Packit 857059
 * 
Packit 857059
 * Description:
Packit 857059
 *	Destroys a request manager.
Packit 857059
 * 
Packit 857059
 * Inputs:
Packit 857059
 *	pReqMgr				- Pointer to a request manager.
Packit 857059
 *
Packit 857059
 * Outputs:
Packit 857059
 *	None.
Packit 857059
 * 
Packit 857059
 * Returns:
Packit 857059
 *	None.
Packit 857059
 * 
Packit 857059
 ****************************************************************************/
Packit 857059
void
Packit 857059
ReqMgrDestroy(
Packit 857059
	IN REQ_MGR* const pReqMgr );
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * ReqMgrGet
Packit 857059
 * 
Packit 857059
 * Description:
Packit 857059
 *	Retrieves a number of objects, either synchronously or asynchronously.
Packit 857059
 * 
Packit 857059
 * Inputs:
Packit 857059
 *	pReqMgr		- Pointer to a request manager.
Packit 857059
 *	pCount		- Contains the number of objects to retrieve.
Packit 857059
 *	ReqType		- Type of get operation.  Can be ReqGetSync, ReqGetAsync, or
Packit 857059
 *				ReqGetAsyncPartialOk.
Packit 857059
 *	pfnCallback	- Pointer to a callback function to store for the request.
Packit 857059
 *	Context1	- First of two contexts. 
Packit 857059
 *	Context2	- Second of two contexts.
Packit 857059
 *
Packit 857059
 * Outputs:
Packit 857059
 *	pCount		- Contains the number of objects available.
Packit 857059
 * 
Packit 857059
 * Returns:
Packit 857059
 *	FSUCCESS	- The request callback has been invoked with elements to 
Packit 857059
 *				satisfy the request.  If the request allowed partial 
Packit 857059
 *				completions, all elements are guaranteed to have been returned.
Packit 857059
 *	FPENDING	- The request could not complete in it's entirety.  If the 
Packit 857059
 *				request allowed partial completion, some elements may have been
Packit 857059
 *				already returned.
Packit 857059
 *	FINSUFFICIENT_RESOURCES	- There were not enough objects for the request to 
Packit 857059
 *							succeed.
Packit 857059
 *	FINSUFFICIENT_MEMORY	- There was not enough memory to process the 
Packit 857059
 *							request (including queuing the request).
Packit 857059
 * 
Packit 857059
 ****************************************************************************/
Packit 857059
FSTATUS
Packit 857059
ReqMgrGet(
Packit 857059
	IN REQ_MGR* const pReqMgr,
Packit 857059
	IN OUT uint32* const pCount,
Packit 857059
	IN const REQ_MGR_TYPE ReqType,
Packit 857059
	IN REQ_CALLBACK pfnCallback,
Packit 857059
	IN void* const Context1,
Packit 857059
	IN void* const Context2 );
Packit 857059
Packit 857059
Packit 857059
/****************************************************************************
Packit 857059
 * ReqMgrResume
Packit 857059
 * 
Packit 857059
 * Description:
Packit 857059
 *	Continues (and completes if possible) a pending request for objects, 
Packit 857059
 *	if any.
Packit 857059
 * 
Packit 857059
 * Inputs:
Packit 857059
 *	pReqMgr		- Pointer to a request manager.
Packit 857059
 *
Packit 857059
 * Outputs:
Packit 857059
 *	pCount		- Number of objects available for a resuming request.
Packit 857059
 *	pContext1	- Contains the Context1 value for the resuming request,
Packit 857059
 *				as provided in the ReqMgrGet function.
Packit 857059
 *	pContext2	- Contains the Context2 value for the resuming request,
Packit 857059
 *				as provided in the ReqMgrGet function.
Packit 857059
 * 
Packit 857059
 * Returns:
Packit 857059
 *	FSUCCESS				- A request was completed.
Packit 857059
 *	FNOT_DONE				- There were no pending requests.
Packit 857059
 *	FINSUFFICIENT_RESOURCES	- There were not enough resources to complete a
Packit 857059
 *							pending request.
Packit 857059
 *	FPENDING				- A request was continued, but not completed.
Packit 857059
 *
Packit 857059
 * Remarks:
Packit 857059
 *	At most one requset is resumed.
Packit 857059
 * 
Packit 857059
 ****************************************************************************/
Packit 857059
FSTATUS 
Packit 857059
ReqMgrResume(
Packit 857059
	IN REQ_MGR* const pReqMgr,
Packit 857059
	OUT uint32* const pCount,
Packit 857059
	OUT REQ_CALLBACK* const ppfnCallback,
Packit 857059
	OUT void** const pContext1,
Packit 857059
	OUT void** const pContext2 );
Packit 857059
Packit 857059
Packit 857059
#ifdef __cplusplus
Packit 857059
}
Packit 857059
#endif
Packit 857059
Packit 857059
#endif	/* _IBA_PUBLIC_IREQ_MGR_H_ */