linux/drivers/mxc/security/sahara2/sah_queue_manager.c File Reference

This file provides a Queue Manager implementation. More...

Functions

sah_Head_Descsah_Find_With_State (sah_Queue_Status state)
fsl_shw_return_t sah_Queue_Manager_Init (void)
void sah_Queue_Manager_Close (void)
int sah_Queue_Manager_Count_Entries (int ignore_state, sah_Queue_Status state)
void sah_Queue_Manager_Remove_Entry (sah_Head_Desc *entry)
void sah_Queue_Manager_Append_Entry (sah_Head_Desc *entry)
void sah_Queue_Manager_Reset_Entries (void)
void sah_Queue_Manager_Prime (sah_Head_Desc *entry)
void sah_reset_sahara_request (void)
void sah_process_finished_request (sah_Head_Desc *desc_head, unsigned error)
void sah_postprocess_queue (unsigned long reset_flag)
fsl_shw_return_t sah_convert_error_status (uint32_t error_status)

Variables

os_lock_t desc_queue_lock
sah_Queuemain_queue = NULL
wait_queue_head_t * int_queue

Detailed Description

This file provides a Queue Manager implementation.

The Queue Manager manages additions and removal from the queue and updates the status of queue entries. It also calls sah_HW_* functions to interract with the hardware.


Function Documentation

fsl_shw_return_t sah_convert_error_status ( uint32_t  error_status  ) 

Process the value from the Sahara error status register and convert it into an FSL SHW API error code.

Warning, this routine must only be called if an error exists.

Parameters:
error_status The value from the error status register.
Returns:
A return code of type fsl_shw_return_t.

References FSL_RETURN_ERROR_S, and FSL_RETURN_INTERNAL_ERROR_S.

Referenced by sah_process_finished_request().

sah_Head_Desc* sah_Find_With_State ( sah_Queue_Status  state  ) 

Handle the IDLE state.

This is a helper function for Queue Manager. This function finds the first entry in the Queue Manager's queue whose state matches the given input state. This function starts at the head of the queue and works towards the tail. If a matching entry was found, the address of the entry is returned.

Parameters:
state A sah_Queue_Status value.
Precondition:
The desc_queue_lock must be held before calling this function.
Returns:
A pointer to a sah_Head_Desc that matches the given state.
NULL otherwise.

References sah_Queue::head, sah_Head_Desc::next, and sah_Head_Desc::status.

Referenced by sah_Handle_Interrupt(), sah_postprocess_queue(), sah_Queue_Manager_Append_Entry(), sah_Queue_Manager_Prime(), and sah_reset_sahara_request().

void sah_postprocess_queue ( unsigned long  reset_flag  ) 
void sah_process_finished_request ( sah_Head_Desc desc_head,
unsigned  error 
)

Post-process a descriptor chain after the hardware has finished with it.

The status of the descriptor could also be checked. (for FATAL or IGNORED).

Parameters:
desc_head The finished chain
error A boolean to mark whether hardware reported error
Precondition:
The desc_queue_lock may not be held when calling this function.

References fsl_shw_uco_t::callback, sah_Head_Desc::desc, desc_queue_lock, sah_Head_Desc::error_status, sah_Head_Desc::fault_address, FSL_RETURN_ERROR_S, FSL_RETURN_OK_S, FSL_UCO_BLOCKING_MODE, FSL_UCO_CALLBACK_MODE, int_queue, os_lock_save_context, os_unlock_restore_context, sah_Head_Desc::result, sah_convert_error_status(), sah_Queue_Append_Entry(), sah_Head_Desc::status, sah_Head_Desc::uco_flags, and sah_Head_Desc::user_info.

Referenced by sah_postprocess_queue().

void sah_Queue_Manager_Append_Entry ( sah_Head_Desc entry  ) 

Appends an entry to the Queue Manager's queue.

This function appends an entry to the Queue Managers queue. It primes SAHARA if this entry is the first PENDING entry in the Queue Manager's Queue.

Parameters:
entry A pointer to a sah_Head_Desc to append to the Queue Manager's queue.
Precondition:
The desc_queue_lock may not may be held when calling this function.
Returns:
void

References desc_queue_lock, os_lock_save_context, os_unlock_restore_context, sah_Find_With_State(), sah_Queue_Append_Entry(), sah_Queue_Manager_Prime(), and sah_Head_Desc::status.

Referenced by adaptor_Exec_Descriptor_Chain(), handle_sah_ioctl_dar(), and sah_blocking_mode().

void sah_Queue_Manager_Close ( void   ) 

Close the Queue Manager.

This function closes the Queue Manager

Returns:
void

References sah_Queue::count, and sah_Queue_Destroy().

Referenced by OS_DEV_SHUTDOWN().

int sah_Queue_Manager_Count_Entries ( int  ignore_state,
sah_Queue_Status  state 
)

Count the number of entries on the Queue Manager's queue

Parameters:
ignore_state If non-zero, the state parameter is ignored. If zero, only entries matching state are counted.
state State of entry to match for counting.
Returns:
Number of entries which matched criteria

References sah_Queue::head, sah_Head_Desc::next, and sah_Head_Desc::status.

fsl_shw_return_t sah_Queue_Manager_Init ( void   ) 

Initialise the Queue Manager.

This function initialises the Queue Manager

Returns:
FSL_RETURN_OK_S on success; FSL_RETURN_MEMORY_ERROR_S if not

References desc_queue_lock, FSL_RETURN_MEMORY_ERROR_S, FSL_RETURN_OK_S, os_lock_alloc_init(), and sah_Queue_Construct().

Referenced by OS_DEV_INIT().

void sah_Queue_Manager_Prime ( sah_Head_Desc entry  ) 

Prime SAHARA.

This function primes SAHARA for the first time or after the queue becomes empty. Queue lock must have been set by the caller of this routine.

Parameters:
entry A pointer to a sah_Head_Desc to Prime SAHARA with.
Returns:
void

References sah_Head_Desc::desc, sah_Find_With_State(), sah_HW_Read_DAR(), sah_HW_Write_DAR(), and sah_Head_Desc::status.

Referenced by sah_Queue_Manager_Append_Entry(), and sah_reset_sahara_request().

void sah_Queue_Manager_Remove_Entry ( sah_Head_Desc entry  ) 

Remove an entry from the Queue Manager's queue.

This function removes an entry from the Queue Manager's queue. The entry to be removed can be anywhere in the queue.

Parameters:
entry A pointer to a sah_Head_Desc to remove from the Queue Manager's queue.
Precondition:
The desc_queue_lock must be held before calling this function.
Returns:
void

References sah_Queue_Remove_Any_Entry().

void sah_Queue_Manager_Reset_Entries ( void   ) 

Mark all entries with state SAH_STATE_RESET.

This function marks all entries in the Queue Manager's queue with state SAH_STATE_RESET.

Returns:
void
Note:
This feature needs re-visiting

References sah_Queue::head, sah_Head_Desc::next, and sah_Head_Desc::status.

Referenced by OS_DEV_IOCTL().

void sah_reset_sahara_request ( void   ) 

Reset SAHARA, then load the next descriptor on it, if one exists

References desc_queue_lock, os_lock_save_context, os_unlock_restore_context, sah_Find_With_State(), sah_HW_Reset(), and sah_Queue_Manager_Prime().

Referenced by sah_postprocess_queue().


Variable Documentation

This lock must be held while performing any queuing or unqueuing functions, including reading the first pointer on the queue. It also protects reading and writing the Sahara DAR register. It must be held during a read-write operation on the DAR so that the 'test-and-set' is atomic.

Referenced by sah_blocking_mode(), sah_get_results_from_pool(), sah_Handle_Interrupt(), sah_postprocess_queue(), sah_process_finished_request(), sah_Queue_Manager_Append_Entry(), sah_Queue_Manager_Init(), and sah_reset_sahara_request().

wait_queue_head_t* int_queue

This is set by the Initialisation function

Referenced by sah_process_finished_request().

This is the main queue for the driver. This is shared between all threads and is not protected by mutexes since the kernel is non-preemptable.

Referenced by sah_blocking_mode().

footer
©  Freescale Semiconductor, Inc., 2007.  All rights reserved.
Freescale Confidential Proprietary
NDA Required
doxygen