src/ssx/occhw/occhw_async_ocb.c
/// Create a request for an OCB circular queue
///
/// \param request An uninitialized or otherwise idle OcbRequest.
///
/// \param queue An async queue for an OCB circular buffer.  The queue \a
/// engine determines whether this is a read or write request.
///
/// \param data A pointer to the data to be moved (for write) or where the
/// data should be placed (for read).
///
/// \param bytes The number of bytes of data to move.  The OCB
/// circular buffers always move multiples of 8 bytes, and the number of bytes
/// must be a multiple of 8.  Higher-level abstractions will have to take care
/// of cases where the numbers of bytes are not multiples of 8.
///
/// \param timeout If not specified as SSX_WAIT_FOREVER, then this request
/// will be governed by a private watchdog timer that will cancel a queued job
/// or kill a running job if the hardware operation does not complete before
/// it times out.
///
/// \param callback The callback to execute when the data move completes, or
/// NULL (0) to indicate no callback.
///
/// \param arg The parameter to the callback routine; ignored if the \a
/// callback is NULL.
///
/// \param options Options to control request priority, callback context and
/// blocking.
///
/// This routine has no way to know if the OcbRequest structure is currently
/// in use, so this API should only be called on uninitialized or otherwise
/// idle OcbRequest structures.
///
/// \retval 0 Success
///
/// \retval -ASYNC_INVALID_OBJECT_OCB_REQUEST The \a request or \a queue were NULL (0), or
/// the \a queue is not an initialized OcbQueue.
///
/// \retval -ASYNC_INVALID_ARGUMENT_OCB_REQUEST The \a data pointer is
/// NULL (0), or the number of bytes is not a multiple of 8.
///
/// See async_request_create() for other errors that may be returned by this
/// call.
Create a request for an OCB circular queue
\param request An uninitialized or otherwise idle OcbRequest.

\param queue An async queue for an OCB circular buffer.  The queue \a
engine determines whether this is a read or write request.

\param data A pointer to the data to be moved (for write) or where the
data should be placed (for read).

\param bytes The number of bytes of data to move.  The OCB
circular buffers always move multiples of 8 bytes, and the number of bytes
must be a multiple of 8.  Higher-level abstractions will have to take care
of cases where the numbers of bytes are not multiples of 8.

\param timeout If not specified as SSX_WAIT_FOREVER, then this request
will be governed by a private watchdog timer that will cancel a queued job
or kill a running job if the hardware operation does not complete before
it times out.

\param callback The callback to execute when the data move completes, or
NULL (0) to indicate no callback.

\param arg The parameter to the callback routine; ignored if the \a
callback is NULL.

\param options Options to control request priority, callback context and
blocking.

This routine has no way to know if the OcbRequest structure is currently
in use, so this API should only be called on uninitialized or otherwise
idle OcbRequest structures.

\retval 0 Success

\retval -ASYNC_INVALID_OBJECT_OCB_REQUEST The \a request or \a queue were NULL (0), or
the \a queue is not an initialized OcbQueue.

\retval -ASYNC_INVALID_ARGUMENT_OCB_REQUEST The \a data pointer is
NULL (0), or the number of bytes is not a multiple of 8.

See async_request_create() for other errors that may be returned by this
call.
Create a request for an OCB circular queue \ param request An uninitialized or otherwise idle OcbRequest . \ param queue An async queue for an OCB circular buffer . The queue \ a engine determines whether this is a read or write request . \ param data A pointer to the data to be moved ( for write ) or where the data should be placed ( for read ) . \ param bytes The number of bytes of data to move . The OCB circular buffers always move multiples of 8 bytes and the number of bytes must be a multiple of 8 . Higher - level abstractions will have to take care of cases where the numbers of bytes are not multiples of 8 . \ param timeout If not specified as SSX_WAIT_FOREVER then this request will be governed by a private watchdog timer that will cancel a queued job or kill a running job if the hardware operation does not complete before it times out . \ param callback The callback to execute when the data move completes or NULL ( 0 ) to indicate no callback . \ param arg The parameter to the callback routine ; ignored if the \ a callback is NULL . \ param options Options to control request priority callback context and blocking . This routine has no way to know if the OcbRequest structure is currently in use so this API should only be called on uninitialized or otherwise idle OcbRequest structures . \ retval 0 Success \ retval - ASYNC_INVALID_OBJECT_OCB_REQUEST The \ a request or \ a queue were NULL ( 0 ) or the \ a queue is not an initialized OcbQueue . \ retval - ASYNC_INVALID_ARGUMENT_OCB_REQUEST The \ a data pointer is NULL ( 0 ) or the number of bytes is not a multiple of 8 . See async_request_create () for other errors that may be returned by this call .
int
ocb_request_create(OcbRequest* request,
                   OcbQueue* queue,
                   uint64_t* data,
                   size_t bytes,
                   SsxInterval timeout,
                   AsyncRequestCallback callback,
                   void* arg,
                   int options)
{
    int rc;
    AsyncRunMethod run_method = 0; 
    AsyncQueue* async_queue = (AsyncQueue*)queue;
    if (SSX_ERROR_CHECK_API)
    {
        SSX_ERROR_IF((request == 0) ||
                     (queue == 0)   ||
                     !(async_queue->engine & ASYNC_ENGINE_OCB),
                     ASYNC_INVALID_OBJECT_OCB_REQUEST);
        SSX_ERROR_IF((data == 0)  ||
                     (bytes % 8),
                     ASYNC_INVALID_ARGUMENT_OCB_REQUEST);
    }
    switch (async_queue->engine)
    {
        case ASYNC_ENGINE_OCB_PULL0:
        case ASYNC_ENGINE_OCB_PULL1:
        case ASYNC_ENGINE_OCB_PULL2:
        case ASYNC_ENGINE_OCB_PULL3:
            run_method = ocb_write_method;
            break;
        case ASYNC_ENGINE_OCB_PUSH0:
        case ASYNC_ENGINE_OCB_PUSH1:
        case ASYNC_ENGINE_OCB_PUSH2:
        case ASYNC_ENGINE_OCB_PUSH3:
            run_method = ocb_read_method;
            break;
    }
    rc = async_request_create(&(request->request),
                              async_queue,
                              run_method,
                              ocb_async_error_method,
                              timeout,
                              callback,
                              arg,
                              options);
    request->data = data;
    request->bytes = bytes;
    return rc;
}
int ocb_request_create ( OcbRequest * request , OcbQueue * queue , uint64_t * data , size_t bytes , SsxInterval timeout , AsyncRequestCallback callback , void * arg , int options ) { int rc ; AsyncRunMethod run_method = 0 ; AsyncQueue * async_queue = ( AsyncQueue * ) queue ; if ( SSX_ERROR_CHECK_API ) { SSX_ERROR_IF ( ( request == 0 ) || ( queue == 0 ) || ! ( async_queue -> engine & ASYNC_ENGINE_OCB ) , ASYNC_INVALID_OBJECT_OCB_REQUEST ) ; SSX_ERROR_IF ( ( data == 0 ) || ( bytes % 8 ) , ASYNC_INVALID_ARGUMENT_OCB_REQUEST ) ; } switch ( async_queue -> engine ) { case ASYNC_ENGINE_OCB_PULL0 : case ASYNC_ENGINE_OCB_PULL1 : case ASYNC_ENGINE_OCB_PULL2 : case ASYNC_ENGINE_OCB_PULL3 : run_method = ocb_write_method ; break ; case ASYNC_ENGINE_OCB_PUSH0 : case ASYNC_ENGINE_OCB_PUSH1 : case ASYNC_ENGINE_OCB_PUSH2 : case ASYNC_ENGINE_OCB_PUSH3 : run_method = ocb_read_method ; break ; } rc = async_request_create ( & ( request -> request ) , async_queue , run_method , ocb_async_error_method , timeout , callback , arg , options ) ; request -> data = data ; request -> bytes = bytes ; return rc ; }
Create a request for an OCB circular queue
\param request An uninitialized or otherwise idle OcbRequest.
Create a request for an OCB circular queue \ param request An uninitialized or otherwise idle OcbRequest .
// Make GCC Happy