|
Packit |
13e616 |
/*
|
|
Packit |
13e616 |
* Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
|
|
Packit |
13e616 |
* Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
|
|
Packit |
13e616 |
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* This software is available to you under a choice of one of two
|
|
Packit |
13e616 |
* licenses. You may choose to be licensed under the terms of the GNU
|
|
Packit |
13e616 |
* General Public License (GPL) Version 2, available from the file
|
|
Packit |
13e616 |
* COPYING in the main directory of this source tree, or the
|
|
Packit |
13e616 |
* OpenIB.org BSD license below:
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* Redistribution and use in source and binary forms, with or
|
|
Packit |
13e616 |
* without modification, are permitted provided that the following
|
|
Packit |
13e616 |
* conditions are met:
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* - Redistributions of source code must retain the above
|
|
Packit |
13e616 |
* copyright notice, this list of conditions and the following
|
|
Packit |
13e616 |
* disclaimer.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* - Redistributions in binary form must reproduce the above
|
|
Packit |
13e616 |
* copyright notice, this list of conditions and the following
|
|
Packit |
13e616 |
* disclaimer in the documentation and/or other materials
|
|
Packit |
13e616 |
* provided with the distribution.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
Packit |
13e616 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
Packit |
13e616 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
Packit |
13e616 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
Packit |
13e616 |
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
Packit |
13e616 |
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit |
13e616 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
Packit |
13e616 |
* SOFTWARE.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
*/
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
/*
|
|
Packit |
13e616 |
* Abstract:
|
|
Packit |
13e616 |
* Declaration of event abstraction.
|
|
Packit |
13e616 |
*/
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
#ifndef _CL_EVENT_H_
|
|
Packit |
13e616 |
#define _CL_EVENT_H_
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
/* Indicates that waiting on an event should never timeout */
|
|
Packit |
13e616 |
#define EVENT_NO_TIMEOUT 0xFFFFFFFF
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
#include <complib/cl_event_osd.h>
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
#ifdef __cplusplus
|
|
Packit |
13e616 |
# define BEGIN_C_DECLS extern "C" {
|
|
Packit |
13e616 |
# define END_C_DECLS }
|
|
Packit |
13e616 |
#else /* !__cplusplus */
|
|
Packit |
13e616 |
# define BEGIN_C_DECLS
|
|
Packit |
13e616 |
# define END_C_DECLS
|
|
Packit |
13e616 |
#endif /* __cplusplus */
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
BEGIN_C_DECLS
|
|
Packit |
13e616 |
/****h* Component Library/Event
|
|
Packit |
13e616 |
* NAME
|
|
Packit |
13e616 |
* Event
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* DESCRIPTION
|
|
Packit |
13e616 |
* The Event provides the ability to suspend and wakeup a thread.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* The event functions operates on a cl_event_t structure which should be
|
|
Packit |
13e616 |
* treated as opaque and should be manipulated only through the provided
|
|
Packit |
13e616 |
* functions.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SEE ALSO
|
|
Packit |
13e616 |
* Structures:
|
|
Packit |
13e616 |
* cl_event_t
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* Initialization/Destruction:
|
|
Packit |
13e616 |
* cl_event_construct, cl_event_init, cl_event_destroy
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* Manipulation:
|
|
Packit |
13e616 |
* cl_event_signal, cl_event_reset, cl_event_wait_on
|
|
Packit |
13e616 |
*********/
|
|
Packit |
13e616 |
/****f* Component Library: Event/cl_event_construct
|
|
Packit |
13e616 |
* NAME
|
|
Packit |
13e616 |
* cl_event_construct
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* DESCRIPTION
|
|
Packit |
13e616 |
* The cl_event_construct function constructs an event.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SYNOPSIS
|
|
Packit |
13e616 |
*/
|
|
Packit |
13e616 |
void cl_event_construct(IN cl_event_t * const p_event);
|
|
Packit |
13e616 |
/*
|
|
Packit |
13e616 |
* PARAMETERS
|
|
Packit |
13e616 |
* p_event
|
|
Packit |
13e616 |
* [in] Pointer to an cl_event_t structure to construct.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* RETURN VALUE
|
|
Packit |
13e616 |
* This function does not return a value.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* NOTES
|
|
Packit |
13e616 |
* Allows calling cl_event_destroy without first calling cl_event_init.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* Calling cl_event_construct is a prerequisite to calling any other event
|
|
Packit |
13e616 |
* function except cl_event_init.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SEE ALSO
|
|
Packit |
13e616 |
* Event, cl_event_init, cl_event_destroy
|
|
Packit |
13e616 |
*********/
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
/****f* Component Library: Event/cl_event_init
|
|
Packit |
13e616 |
* NAME
|
|
Packit |
13e616 |
* cl_event_init
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* DESCRIPTION
|
|
Packit |
13e616 |
* The cl_event_init function initializes an event for use.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SYNOPSIS
|
|
Packit |
13e616 |
*/
|
|
Packit |
13e616 |
cl_status_t
|
|
Packit |
13e616 |
cl_event_init(IN cl_event_t * const p_event, IN const boolean_t manual_reset);
|
|
Packit |
13e616 |
/*
|
|
Packit |
13e616 |
* PARAMETERS
|
|
Packit |
13e616 |
* p_event
|
|
Packit |
13e616 |
* [in] Pointer to an cl_event_t structure to initialize.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* manual_reset
|
|
Packit |
13e616 |
* [in] If FALSE, indicates that the event resets itself after releasing
|
|
Packit |
13e616 |
* a single waiter. If TRUE, the event remains in the signalled state
|
|
Packit |
13e616 |
* until explicitly reset by a call to cl_event_reset.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* RETURN VALUES
|
|
Packit |
13e616 |
* CL_SUCCESS if event initialization succeeded.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* CL_ERROR otherwise.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* NOTES
|
|
Packit |
13e616 |
* Allows calling event manipulation functions, such as cl_event_signal,
|
|
Packit |
13e616 |
* cl_event_reset, and cl_event_wait_on.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* The event is initially in a reset state.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SEE ALSO
|
|
Packit |
13e616 |
* Event, cl_event_construct, cl_event_destroy, cl_event_signal,
|
|
Packit |
13e616 |
* cl_event_reset, cl_event_wait_on
|
|
Packit |
13e616 |
*********/
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
/****f* Component Library: Event/cl_event_destroy
|
|
Packit |
13e616 |
* NAME
|
|
Packit |
13e616 |
* cl_event_destroy
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* DESCRIPTION
|
|
Packit |
13e616 |
* The cl_event_destroy function performs any necessary cleanup of an event.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SYNOPSIS
|
|
Packit |
13e616 |
*/
|
|
Packit |
13e616 |
void cl_event_destroy(IN cl_event_t * const p_event);
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
/*
|
|
Packit |
13e616 |
* PARAMETERS
|
|
Packit |
13e616 |
* p_event
|
|
Packit |
13e616 |
* [in] Pointer to an cl_event_t structure to destroy.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* RETURN VALUE
|
|
Packit |
13e616 |
* This function does not return a value.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* NOTES
|
|
Packit |
13e616 |
* This function should only be called after a call to cl_event_construct
|
|
Packit |
13e616 |
* or cl_event_init.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SEE ALSO
|
|
Packit |
13e616 |
* Event, cl_event_construct, cl_event_init
|
|
Packit |
13e616 |
*********/
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
/****f* Component Library: Event/cl_event_signal
|
|
Packit |
13e616 |
* NAME
|
|
Packit |
13e616 |
* cl_event_signal
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* DESCRIPTION
|
|
Packit |
13e616 |
* The cl_event_signal function sets an event to the signalled state and
|
|
Packit |
13e616 |
* releases at most one waiting thread.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SYNOPSIS
|
|
Packit |
13e616 |
*/
|
|
Packit |
13e616 |
cl_status_t cl_event_signal(IN cl_event_t * const p_event);
|
|
Packit |
13e616 |
/*
|
|
Packit |
13e616 |
* PARAMETERS
|
|
Packit |
13e616 |
* p_event
|
|
Packit |
13e616 |
* [in] Pointer to an cl_event_t structure to set.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* RETURN VALUES
|
|
Packit |
13e616 |
* CL_SUCCESS if the event was successfully signalled.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* CL_ERROR otherwise.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* NOTES
|
|
Packit |
13e616 |
* For auto-reset events, the event is reset automatically once a wait
|
|
Packit |
13e616 |
* operation is satisfied.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* Triggering the event multiple times does not guarantee that the same
|
|
Packit |
13e616 |
* number of wait operations are satisfied. This is because events are
|
|
Packit |
13e616 |
* either in a signalled on non-signalled state, and triggering an event
|
|
Packit |
13e616 |
* that is already in the signalled state has no effect.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SEE ALSO
|
|
Packit |
13e616 |
* Event, cl_event_reset, cl_event_wait_on
|
|
Packit |
13e616 |
*********/
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
/****f* Component Library: Event/cl_event_reset
|
|
Packit |
13e616 |
* NAME
|
|
Packit |
13e616 |
* cl_event_reset
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* DESCRIPTION
|
|
Packit |
13e616 |
* The cl_event_reset function sets an event to the non-signalled state.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SYNOPSIS
|
|
Packit |
13e616 |
*/
|
|
Packit |
13e616 |
cl_status_t cl_event_reset(IN cl_event_t * const p_event);
|
|
Packit |
13e616 |
/*
|
|
Packit |
13e616 |
* PARAMETERS
|
|
Packit |
13e616 |
* p_event
|
|
Packit |
13e616 |
* [in] Pointer to an cl_event_t structure to reset.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* RETURN VALUES
|
|
Packit |
13e616 |
* CL_SUCCESS if the event was successfully reset.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* CL_ERROR otherwise.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SEE ALSO
|
|
Packit |
13e616 |
* Event, cl_event_signal, cl_event_wait_on
|
|
Packit |
13e616 |
*********/
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
/****f* Component Library: Event/cl_event_wait_on
|
|
Packit |
13e616 |
* NAME
|
|
Packit |
13e616 |
* cl_event_wait_on
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* DESCRIPTION
|
|
Packit |
13e616 |
* The cl_event_wait_on function waits for the specified event to be
|
|
Packit |
13e616 |
* triggered for a minimum amount of time.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SYNOPSIS
|
|
Packit |
13e616 |
*/
|
|
Packit |
13e616 |
cl_status_t
|
|
Packit |
13e616 |
cl_event_wait_on(IN cl_event_t * const p_event,
|
|
Packit |
13e616 |
IN const uint32_t wait_us, IN const boolean_t interruptible);
|
|
Packit |
13e616 |
/*
|
|
Packit |
13e616 |
* PARAMETERS
|
|
Packit |
13e616 |
* p_event
|
|
Packit |
13e616 |
* [in] Pointer to an cl_event_t structure on which to wait.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* wait_us
|
|
Packit |
13e616 |
* [in] Number of microseconds to wait.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* interruptible
|
|
Packit |
13e616 |
* [in] Indicates whether the wait operation can be interrupted
|
|
Packit |
13e616 |
* by external signals.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* RETURN VALUES
|
|
Packit |
13e616 |
* CL_SUCCESS if the wait operation succeeded in response to the event
|
|
Packit |
13e616 |
* being set.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* CL_TIMEOUT if the specified time period elapses.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* CL_NOT_DONE if the wait was interrupted by an external signal.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* CL_ERROR if the wait operation failed.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* NOTES
|
|
Packit |
13e616 |
* If wait_us is set to EVENT_NO_TIMEOUT, the function will wait until the
|
|
Packit |
13e616 |
* event is triggered and never timeout.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* If the timeout value is zero, this function simply tests the state of
|
|
Packit |
13e616 |
* the event.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* If the event is already on the signalled state at the time of the call
|
|
Packit |
13e616 |
* to cl_event_wait_on, the call completes immediately with CL_SUCCESS.
|
|
Packit |
13e616 |
*
|
|
Packit |
13e616 |
* SEE ALSO
|
|
Packit |
13e616 |
* Event, cl_event_signal, cl_event_reset
|
|
Packit |
13e616 |
*********/
|
|
Packit |
13e616 |
|
|
Packit |
13e616 |
END_C_DECLS
|
|
Packit |
13e616 |
#endif /* _CL_EVENT_H_ */
|