A back-end describes the
dmover functions it can perform using an array of
dmover_algdesc structures:
struct dmover_algdesc {
const char *dad_name; /* algorithm name */
void *dad_data; /* opaque algorithm description */
int dad_ninputs; /* number of inputs */
};
The
dad_name member points to a valid
dmover function name which the client may specify. The
dad_data member points to a back-end-specific description of the algorithm.
A back-end presents itself to the
dmover facility using the
dmover_backend structure. The back-end must initialize the following members of the structure:
const char *dmb_name
This is the name of the back-end.
u_int dmb_speed
This is an estimate of the number of kilobytes/second that the back-end can process.
void *dmb_cookie
This is a pointer to back-end private data.
const struct dmover_algdesc *dmb_algdescs
This points to an array of dmover_algdesc structures which describe the functions the data mover can perform.
int dmb_nalgdescs
This is the number of elements in the dmb_algdescs array.
void (*dmb_process)(struct dmover_backend *)
This is the entry point to the back-end used to process requests.
When invoked by the
dmover facility, the back-end's
(*dmb_process)() function should examine the pending request queue in its
dmover_backend structure:
TAILQ_HEAD(, dmover_request) dmb_pendreqs
This is the queue of pending requests.
int dmb_npendreqs
This is the number of requests in the dmb_pendreqs queue.
If an error occurs when processing the request, the
DMOVER_REQ_ERROR bit must be set in the
dreq_flags member of the request, and the
dreq_error member set to an
errno(2) value to indicate the error.
When the back-end has finished processing the request, it must call the
dmover_done() function. This function eventually invokes the client's call-back routine.
If a hardware-assisted data mover uses interrupts, the interrupt handlers should be registered at IPL_VM.
The following functions are provided to the back-ends:
dmover_backend_register(backend)
The
dmover_backend_register() function registers the back-end
backend with the
dmover facility.
dmover_backend_unregister(backend)
The
dmover_backend_unregister() function removes the back-end
backend from the
dmover facility. The back-end must already be registered.
dmover_done(req)
The
dmover_done() function is called by the back-end when it has finished processing a request, whether the request completed successfully or not.
The
dmover_backend_register() and
dmover_backend_unregister() functions must not be called from interrupt context.
The
dmover_done() function may be called at
IPL_VM,
IPL_SOFTCLOCK,
IPL_SOFTNET, or in non-interrupt context.