2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/*
2N/A *
2N/A * MODULE: dapl_evd_dto_callback.c
2N/A *
2N/A * PURPOSE: implements DTO callbacks from verbs
2N/A *
2N/A * $Id: dapl_evd_dto_callb.c,v 1.17 2003/07/30 18:13:38 hobie16 Exp $
2N/A */
2N/A
2N/A#include "dapl.h"
2N/A#include "dapl_evd_util.h"
2N/A#include "dapl_cno_util.h"
2N/A#include "dapl_cookie.h"
2N/A#include "dapl_adapter_util.h"
2N/A
2N/A/*
2N/A * dapl_evd_dto_callback
2N/A *
2N/A * Input:
2N/A * hca_handle_in,
2N/A * cq_handle_in,
2N/A * user_context_cq_p
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * This is invoked for both DTO and MW bind completions. Strictly
2N/A * speaking it is an event callback rather than just a DTO callback.
2N/A *
2N/A */
2N/A
2N/Avoid
2N/Adapl_evd_dto_callback(
2N/A IN ib_hca_handle_t hca_handle,
2N/A IN ib_cq_handle_t cq_handle,
2N/A IN void *user_context)
2N/A{
2N/A DAPL_EVD *evd_ptr;
2N/A DAT_RETURN dat_status;
2N/A DAPL_EVD_STATE state;
2N/A
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
2N/A "dapl_evd_dto_callback(%p, %p, %p)\n",
2N/A hca_handle,
2N/A cq_handle,
2N/A user_context);
2N/A
2N/A evd_ptr = (DAPL_EVD *) user_context;
2N/A
2N/A dapl_os_assert(hca_handle ==
2N/A evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle);
2N/A dapl_os_assert(evd_ptr->ib_cq_handle == cq_handle);
2N/A dapl_os_assert(evd_ptr->header.magic == DAPL_MAGIC_EVD);
2N/A
2N/A /* Read once. */
2N/A state = *(volatile DAPL_EVD_STATE *) &evd_ptr->evd_state;
2N/A
2N/A dapl_dbg_log(DAPL_DBG_TYPE_EVD,
2N/A "-- dapl_evd_dto_callback: CQ %p, state %x\n",
2N/A (void *)evd_ptr->ib_cq_handle,
2N/A state);
2N/A
2N/A /*
2N/A * This function does not dequeue from the CQ; only the consumer
2N/A * can do that. Instead, it wakes up waiters if any exist.
2N/A * It rearms the completion only if completions should always occur
2N/A * (specifically if a CNO is associated with the EVD and the
2N/A * EVD is enabled.
2N/A */
2N/A
2N/A if (state == DAPL_EVD_STATE_WAITED) {
2N/A /*
2N/A * If we could, it would be best to avoid this wakeup
2N/A * (and the context switch) unless the number of events/CQs
2N/A * waiting for the waiter was its threshold. We don't
2N/A * currently have the ability to determine that without
2N/A * dequeueing the events, and we can't do that for
2N/A * synchronization reasons (racing with the waiter waking
2N/A * up and dequeuing, sparked by other callbacks).
2N/A */
2N/A
2N/A /*
2N/A * We don't need to worry about taking the lock for the
2N/A * wakeup because wakeups are sticky.
2N/A */
2N/A (void) dapl_os_wait_object_wakeup(&evd_ptr->wait_object);
2N/A } else if (state == DAPL_EVD_STATE_OPEN) {
2N/A DAPL_CNO *cno = evd_ptr->cno_ptr;
2N/A if (evd_ptr->evd_enabled && (evd_ptr->cno_ptr != NULL)) {
2N/A /*
2N/A * Re-enable callback, *then* trigger.
2N/A * This guarantees we won't miss any events.
2N/A */
2N/A dat_status = DAPL_NOTIFY(evd_ptr)(
2N/A evd_ptr->ib_cq_handle, IB_NOTIFY_ON_NEXT_COMP, 0);
2N/A
2N/A if (DAT_SUCCESS != dat_status) {
2N/A (void) dapls_evd_post_async_error_event(
2N/A evd_ptr->header.owner_ia->async_error_evd,
2N/A DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR,
2N/A (DAT_IA_HANDLE)evd_ptr->header.owner_ia);
2N/A }
2N/A
2N/A dapl_cno_trigger(cno, evd_ptr);
2N/A }
2N/A }
2N/A dapl_dbg_log(DAPL_DBG_TYPE_RTN, "dapl_evd_dto_callback() returns\n");
2N/A}
2N/A
2N/A/*
2N/A * Local variables:
2N/A * c-indent-level: 4
2N/A * c-basic-offset: 4
2N/A * tab-width: 8
2N/A * End:
2N/A */