zfcp_qdio_handler_error_check(struct zfcp_adapter *adapter, unsigned int status, unsigned int qdio_error, unsigned int siga_error) 
zfcp_qdio_handler_error_check(struct zfcp_adapter *adapter, unsigned int status, unsigned int qdio_error, unsigned int siga_error, int first_element, int elements_processed) 
static qdio_handler_t zfcp_qdio_request_handler;static qdio_handler_t zfcp_qdio_response_handler;static int zfcp_qdio_handler_error_check(struct zfcp_adapter *,					 unsigned int,					 unsigned int, unsigned int);#define ZFCP_LOG_AREA                   ZFCP_LOG_AREA_QDIO/* * Allocates BUFFER memory to each of the pointers of the qdio_buffer_t  * array in the adapter struct. * Cur_buf is the pointer array and count can be any number of required  * buffers, the page-fitting arithmetic is done entirely within this funciton. * * returns:	number of buffers allocated * locks:       must only be called with zfcp_data.config_sema taken */static intzfcp_qdio_buffers_enqueue(struct qdio_buffer **cur_buf, int count){	int buf_pos;	int qdio_buffers_per_page;	int page_pos = 0;	struct qdio_buffer *first_in_page = NULL;	qdio_buffers_per_page = PAGE_SIZE / sizeof (struct qdio_buffer);	ZFCP_LOG_TRACE("buffers_per_page=%d\n", qdio_buffers_per_page);	for (buf_pos = 0; buf_pos < count; buf_pos++) {		if (page_pos == 0) {			cur_buf[buf_pos] = (struct qdio_buffer *)			    get_zeroed_page(GFP_KERNEL);			if (cur_buf[buf_pos] == NULL) {				ZFCP_LOG_INFO("error: allocation of "					      "QDIO buffer failed \n");				goto out;			}			first_in_page = cur_buf[buf_pos];		} else {			cur_buf[buf_pos] = first_in_page + page_pos;		}		/* was initialised to zero */		page_pos++;		page_pos %= qdio_buffers_per_page;	} out:	return buf_pos;}/* * Frees BUFFER memory for each of the pointers of the struct qdio_buffer array * in the adapter struct cur_buf is the pointer array and count can be any * number of buffers in the array that should be freed starting from buffer 0 * * locks:       must only be called with zfcp_data.config_sema taken */static voidzfcp_qdio_buffers_dequeue(struct qdio_buffer **cur_buf, int count){	int buf_pos;	int qdio_buffers_per_page;	qdio_buffers_per_page = PAGE_SIZE / sizeof (struct qdio_buffer);	ZFCP_LOG_TRACE("buffers_per_page=%d\n", qdio_buffers_per_page);	for (buf_pos = 0; buf_pos < count; buf_pos += qdio_buffers_per_page)		free_page((unsigned long) cur_buf[buf_pos]);	return;}/* locks:       must only be called with zfcp_data.config_sema taken */intzfcp_qdio_allocate_queues(struct zfcp_adapter *adapter){	int buffer_count;	int retval = 0;	buffer_count =	    zfcp_qdio_buffers_enqueue(&(adapter->request_queue.buffer[0]),				      QDIO_MAX_BUFFERS_PER_Q);	if (buffer_count < QDIO_MAX_BUFFERS_PER_Q) {		ZFCP_LOG_DEBUG("only %d QDIO buffers allocated for request "			       "queue\n", buffer_count);		zfcp_qdio_buffers_dequeue(&(adapter->request_queue.buffer[0]),					  buffer_count);		retval = -ENOMEM;		goto out;	}	buffer_count =	    zfcp_qdio_buffers_enqueue(&(adapter->response_queue.buffer[0]),				      QDIO_MAX_BUFFERS_PER_Q);	if (buffer_count < QDIO_MAX_BUFFERS_PER_Q) {		ZFCP_LOG_DEBUG("only %d QDIO buffers allocated for response "			       "queue", buffer_count);		zfcp_qdio_buffers_dequeue(&(adapter->response_queue.buffer[0]),					  buffer_count);		ZFCP_LOG_TRACE("freeing request_queue buffers\n");		zfcp_qdio_buffers_dequeue(&(adapter->request_queue.buffer[0]),					  QDIO_MAX_BUFFERS_PER_Q);		retval = -ENOMEM;		goto out;	} out:	return retval;}/* locks:       must only be called with zfcp_data.config_sema taken */voidzfcp_qdio_free_queues(struct zfcp_adapter *adapter){	ZFCP_LOG_TRACE("freeing request_queue buffers\n");	zfcp_qdio_buffers_dequeue(&(adapter->request_queue.buffer[0]),				  QDIO_MAX_BUFFERS_PER_Q);	ZFCP_LOG_TRACE("freeing response_queue buffers\n");	zfcp_qdio_buffers_dequeue(&(adapter->response_queue.buffer[0]),				  QDIO_MAX_BUFFERS_PER_Q);}intzfcp_qdio_allocate(struct zfcp_adapter *adapter){	struct qdio_initialize *init_data;	init_data = &adapter->qdio_init_data;	init_data->cdev = adapter->ccw_device;	init_data->q_format = QDIO_SCSI_QFMT;	memcpy(init_data->adapter_name, &adapter->name, 8);	init_data->qib_param_field_format = 0;	init_data->qib_param_field = NULL;	init_data->input_slib_elements = NULL;	init_data->output_slib_elements = NULL;	init_data->min_input_threshold = ZFCP_MIN_INPUT_THRESHOLD;	init_data->max_input_threshold = ZFCP_MAX_INPUT_THRESHOLD;	init_data->min_output_threshold = ZFCP_MIN_OUTPUT_THRESHOLD;	init_data->max_output_threshold = ZFCP_MAX_OUTPUT_THRESHOLD;	init_data->no_input_qs = 1;	init_data->no_output_qs = 1;	init_data->input_handler = zfcp_qdio_response_handler;	init_data->output_handler = zfcp_qdio_request_handler;	init_data->int_parm = (unsigned long) adapter;	init_data->flags = QDIO_INBOUND_0COPY_SBALS |	    QDIO_OUTBOUND_0COPY_SBALS | QDIO_USE_OUTBOUND_PCIS;	init_data->input_sbal_addr_array =	    (void **) (adapter->response_queue.buffer);	init_data->output_sbal_addr_array =	    (void **) (adapter->request_queue.buffer);	return qdio_allocate(init_data);}/* * function:   	zfcp_qdio_handler_error_check * * purpose:     called by the response handler to determine error condition * * returns:	error flag * */static inline intzfcp_qdio_handler_error_check(struct zfcp_adapter *adapter,			      unsigned int status,			      unsigned int qdio_error, unsigned int siga_error){	int retval = 0;	if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_TRACE)) {		if (status & QDIO_STATUS_INBOUND_INT) {			ZFCP_LOG_TRACE("status is"				       " QDIO_STATUS_INBOUND_INT \n");		}		if (status & QDIO_STATUS_OUTBOUND_INT) {			ZFCP_LOG_TRACE("status is"				       " QDIO_STATUS_OUTBOUND_INT \n");		}	}	if (unlikely(status & QDIO_STATUS_LOOK_FOR_ERROR)) {		retval = -EIO;		ZFCP_LOG_INFO("QDIO problem occurred (status=0x%x, "			      "qdio_error=0x%x, siga_error=0x%x)\n",			      status, qdio_error, siga_error);		/* Restarting IO on the failed adapter from scratch */		debug_text_event(adapter->erp_dbf, 1, "qdio_err");               /*                * Since we have been using this adapter, it is save to assume                * that it is not failed but recoverable. The card seems to                * report link-up events by self-initiated queue shutdown.                * That is why we need to clear the the link-down flag                * which is set again in case we have missed by a mile.                */               zfcp_erp_adapter_reopen(                       adapter,                        ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |                       ZFCP_STATUS_COMMON_ERP_FAILED);	}	return retval;}/* * function:    zfcp_qdio_request_handler * * purpose:	is called by QDIO layer for completed SBALs in request queue * * returns:	(void) */static voidzfcp_qdio_request_handler(struct ccw_device *ccw_device,			  unsigned int status,			  unsigned int qdio_error,			  unsigned int siga_error,			  unsigned int queue_number,			  int first_element,			  int elements_processed,			  unsigned long int_parm){	struct zfcp_adapter *adapter;	struct zfcp_qdio_queue *queue;	adapter = (struct zfcp_adapter *) int_parm;	queue = &adapter->request_queue;	ZFCP_LOG_DEBUG("adapter %s, first=%d, elements_processed=%d\n",		       zfcp_get_busid_by_adapter(adapter),		       first_element, elements_processed);	if (unlikely(zfcp_qdio_handler_error_check(adapter, status, qdio_error,					           siga_error)))		goto out;	/*	 * we stored address of struct zfcp_adapter  data structure	 * associated with irq in int_parm	 */	/* cleanup all SBALs being program-owned now */	zfcp_qdio_zero_sbals(queue->buffer, first_element, elements_processed);	/* increase free space in outbound queue */	atomic_add(elements_processed, &queue->free_count);	ZFCP_LOG_DEBUG("free_count=%d\n", atomic_read(&queue->free_count));	wake_up(&adapter->request_wq);	ZFCP_LOG_DEBUG("elements_processed=%d, free count=%d\n",		       elements_processed, atomic_read(&queue->free_count)); out:	return;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/8a36e4532ea10471f0a8605207d071361d7be2c3/zfcp_qdio.c/clean/drivers/s390/scsi/zfcp_qdio.c