/************************************************************************* * * FUNCTION * * mcapi_pktchan_free * * DESCRIPTION * * Non-blocking API routine to return a system buffer. * * INPUTS * * *buffer A pointer to the buffer to return. * *mcapi_status A pointer to memory that will be filled in * with the status of the call. * * OUTPUTS * * The number of receive operations that are guaranteed to not block * waiting for incoming data. * *************************************************************************/ void mcapi_pktchan_free(void *buffer, mcapi_status_t *mcapi_status) { MCAPI_BUFFER *cur_buf; /* Validate mcapi_status input parameter. */ if (mcapi_status) { /* Validate buffer input parameter. */ if (buffer) { /* Get the lock. */ mcapi_lock_node_data(); /* Get a pointer to the first buffer on the wait list. */ cur_buf = MCAPI_Buf_Wait_List.head; /* Find the buffer structure associated with this buffer. */ while (cur_buf) { /* If the buffer matches the buffer being free. */ if (cur_buf->buf_ptr == ((unsigned char*)buffer - MCAPI_HEADER_LEN)) { /* Remove this buffer from the Wait List. */ mcapi_remove(&MCAPI_Buf_Wait_List, cur_buf); /* Return the buffer to the list of free buffers. */ ((MCAPI_INTERFACE*)(cur_buf->mcapi_dev_ptr))-> mcapi_recover_buffer(cur_buf); break; } /* Get a pointer to the next buffer. */ cur_buf = (MCAPI_BUFFER*)(cur_buf->next_buf); } /* The buffer was found on the list. */ if (cur_buf) { *mcapi_status = MCAPI_SUCCESS; } /* The buffer was not found. */ else { *mcapi_status = MCAPI_ERR_BUF_INVALID; } /* Release the lock. */ mcapi_unlock_node_data(); } /* The buffer is not valid. */ else { *mcapi_status = MCAPI_ERR_BUF_INVALID; } } }
/************************************************************************* * * FUNCTION * * mcapi_check_foreign_resume * * DESCRIPTION * * Checks if any pending requests from foreign nodes should be resumed. * * INPUTS * * type The type of request to check. * endpoint The endpoint for which the request is * suspended on some action. * status The status to set in the request structure. * * OUTPUTS * * None. * *************************************************************************/ void mcapi_check_foreign_resume(int type, mcapi_endpoint_t endpoint, mcapi_status_t status) { mcapi_request_t *request, *next_ptr; MCAPI_GLOBAL_DATA *node_data; /* Get a pointer to the global node list. */ node_data = mcapi_get_node_data(); /* Get a pointer to the first entry in the request queue. */ request = node_data->mcapi_foreign_req_queue.flink; /* Check each request to see if the operation has been completed. */ while (request) { /* Get a pointer to the next entry. */ next_ptr = request->mcapi_next; switch (type) { /* An endpoint associated with a pending request has been * created. */ case MCAPI_REQ_CREATED: /* If the request structure is waiting for an endpoint to be * created. */ if ( (request->mcapi_type == MCAPI_REQ_CREATED) && (mcapi_encode_endpoint(request->mcapi_target_node_id, request->mcapi_target_port_id) == endpoint) ) { /* Remove this item from the list. */ mcapi_remove(&node_data->mcapi_foreign_req_queue, request); /* Set the status to success. */ request->mcapi_status = MCAPI_SUCCESS; /* Send the response. */ mcapi_tx_response(node_data, request); /* Set this request structure back to available. */ mcapi_release_request_struct(request); } break; default: break; } /* Get the next request entry in the list. */ request = next_ptr; } }
/************************************************************************* * * FUNCTION * * mcapi_resume * * DESCRIPTION * * Resume a specific task. * * INPUTS * * *node_data A pointer to the global MCAPI node data * structure. * *request The request structure associated with the * task to resume. * status The status to set in the request structure. * * OUTPUTS * * None. * *************************************************************************/ void mcapi_resume(MCAPI_GLOBAL_DATA *node_data, mcapi_request_t *request, mcapi_status_t status) { /* Set the status so the blocking operation knows if the operation * completed successfully. */ request->mcapi_status = status; /* Remove this request from the list. */ mcapi_remove(&node_data->mcapi_local_req_queue, request); /* Resume the task. */ MCAPI_Resume_Task(request); }