コード例 #1
0
/**
*Throughout this program, all write operation is not under lock,but all read operation is.
*I think lock or not is depends on different situation.
*/
static int dequeue_manag(struct crypto_priv *localCpg)
{
	int DFlag=0;
	int tooClose=0;
	struct request_handler *rh = NULL;
	int count=0;
	do{
/*		spin_lock_irq(&com->lockOfD);
		if(RTI!=CTI){
			rh = list_entry (RTI, struct request_handler , mylist );
			if(RTI->prev==WTI){
				tooClose=1;
				com->tooClose=1;
			}
			RTI=RTI->next;
			DFlag=1;
			com->numOfTask--;
		}
		spin_unlock_irq(&com->lockOfD);
*/	
		spin_lock_irq(&com->lockOfD);
		if(RTI!=CTI&&!com->tooClose){
			rh = list_entry (RTI, struct request_handler , mylist );
			if(RTI->prev==WTI){
				tooClose=1;
				com->tooClose=1;
			}
			else{
				RTI=RTI->next;
			}
			DFlag=1;
		}		
		spin_unlock_irq(&com->lockOfD);
		if(DFlag){
			DFlag=0;
			printk(KERN_INFO "dequeue_com being called by Dman, with index of %d,numOfTask is %d",rh->index,com->numOfTask);
			dequeue_complete_req(rh->index);
			count++;
			if(tooClose){
				tooClose=0;
				RTI=RTI->next;
				com->tooClose=0;
			}
			com->numOfTask--;
			/*if(count==2){
				printk(KERN_INFO "==========================dequeue twice already"); 
				return 0;
			}*/
		}
		int ret;
		while(!ret)
			ret=wait_event_timeout(wq,RTI!=CTI||com->exitFlag,1000);
		msleep(1000);
		__set_current_state(TASK_UNINTERRUPTIBLE);
	} while (!kthread_should_stop());
コード例 #2
0
static int queue_manag(void *data)
{
	cpg->eng_st = ENGINE_IDLE;
	do {
		struct crypto_async_request *async_req = NULL;
		struct crypto_async_request *backlog;

		__set_current_state(TASK_INTERRUPTIBLE);

		if (cpg->eng_st == ENGINE_W_DEQUEUE)
			dequeue_complete_req();

		spin_lock_irq(&cpg->lock);
		if (cpg->eng_st == ENGINE_IDLE) {
			backlog = crypto_get_backlog(&cpg->queue);
			async_req = crypto_dequeue_request(&cpg->queue);
			if (async_req) {
				BUG_ON(cpg->eng_st != ENGINE_IDLE);
				cpg->eng_st = ENGINE_BUSY;
			}
		}
		spin_unlock_irq(&cpg->lock);

		if (backlog) {
			backlog->complete(backlog, -EINPROGRESS);
			backlog = NULL;
		}

		if (async_req) {
			/*if (async_req->tfm->__crt_alg->cra_type !=
			    &crypto_ahash_type) {*/
				struct ablkcipher_request *req =
				    container_of(async_req,
						 struct ablkcipher_request,
						 base);
				cns3xxx_start_new_crypt_req(req);
			/*} else {
				struct ahash_request *req =
				    ahash_request_cast(async_req);
				cns3xxx_start_new_hash_req(req);
			}*/
			async_req = NULL;
		}

		schedule();

	} while (!kthread_should_stop());


	return 0;
}
コード例 #3
0
static int queue_manag(void *data)
{
	cpg->eng_st = ENGINE_IDLE;
	do {
		struct ablkcipher_request *req;
		struct crypto_async_request *async_req = NULL;
		struct crypto_async_request *backlog;

		__set_current_state(TASK_INTERRUPTIBLE);

		if (cpg->eng_st == ENGINE_W_DEQUEUE)
			dequeue_complete_req();

		spin_lock_irq(&cpg->lock);
		if (cpg->eng_st == ENGINE_IDLE) {
			backlog = crypto_get_backlog(&cpg->queue);
			async_req = crypto_dequeue_request(&cpg->queue);
			if (async_req) {
				BUG_ON(cpg->eng_st != ENGINE_IDLE);
				cpg->eng_st = ENGINE_BUSY;
			}
		}
		spin_unlock_irq(&cpg->lock);

		if (backlog) {
			backlog->complete(backlog, -EINPROGRESS);
			backlog = NULL;
		}

		if (async_req) {
			req = container_of(async_req,
					struct ablkcipher_request, base);
			mv_enqueue_new_req(req);
			async_req = NULL;
		}

		schedule();

	} while (!kthread_should_stop());
	return 0;
}