dapl_ep_reset.c revision 9517:b4839b0aa7a4
167754Smsmith/*
267754Smsmith * CDDL HEADER START
367754Smsmith *
467754Smsmith * The contents of this file are subject to the terms of the
567754Smsmith * Common Development and Distribution License (the "License").
667754Smsmith * You may not use this file except in compliance with the License.
7217365Sjkim *
8306536Sjkim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
970243Smsmith * or http://www.opensolaris.org/os/licensing.
1067754Smsmith * See the License for the specific language governing permissions
11217365Sjkim * and limitations under the License.
12217365Sjkim *
13217365Sjkim * When distributing Covered Code, include this CDDL HEADER in each
14217365Sjkim * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15217365Sjkim * If applicable, add the following below this CDDL HEADER, with the
16217365Sjkim * fields enclosed by brackets "[]" replaced with your own identifying
17217365Sjkim * information: Portions Copyright [yyyy] [name of copyright owner]
18217365Sjkim *
19217365Sjkim * CDDL HEADER END
20217365Sjkim */
21217365Sjkim
22217365Sjkim/*
23217365Sjkim * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
24217365Sjkim */
2567754Smsmith
26217365Sjkim/*
27217365Sjkim * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
28217365Sjkim * Use is subject to license terms.
2967754Smsmith */
30217365Sjkim
31217365Sjkim/*
32217365Sjkim *
33217365Sjkim * MODULE: dapl_ep_reset.c
34217365Sjkim *
35217365Sjkim * PURPOSE: Endpoint management
36217365Sjkim * Description: Interfaces in this file are completely described in
37217365Sjkim *		the DAPL 1.1 API, Chapter 6, section 5.13
38217365Sjkim *
39217365Sjkim * $Id: dapl_ep_reset.c,v 1.6 2003/07/08 14:23:35 sjs2 Exp $
40217365Sjkim */
41217365Sjkim
42217365Sjkim#include "dapl.h"
4367754Smsmith#include "dapl_ia_util.h"
44193341Sjkim#include "dapl_ep_util.h"
45193341Sjkim#include "dapl_adapter_util.h"
46193341Sjkim#include "dapl_ring_buffer_util.h"
47193341Sjkim
48193341Sjkim/*
49306536Sjkim * dapl_ep_reset
5067754Smsmith *
5177424Smsmith * DAPL Requirements Version 1.1, 6.5.13
5291116Smsmith *
5367754Smsmith * Reset the QP attached to this Endpoint, transitioning back to the
54151937Sjkim * INIT state
5567754Smsmith *
56151937Sjkim * Input:
57151937Sjkim *	ep_handle
58151937Sjkim *
59151937Sjkim * Output:
60151937Sjkim *	none
61151937Sjkim *
62151937Sjkim * Returns:
63151937Sjkim *	DAT_SUCCESS
64151937Sjkim *	DAT_INVALID_PARAMETER
65151937Sjkim *	DAT_INVALID_STATE
66151937Sjkim */
67151937SjkimDAT_RETURN
68151937Sjkimdapl_ep_reset(
69151937Sjkim	IN DAT_EP_HANDLE ep_handle)
70167802Sjkim{
71167802Sjkim	DAPL_EP	*ep_ptr;
72167802Sjkim	DAT_RETURN dat_status;
73167802Sjkim
74167802Sjkim	dat_status = DAT_SUCCESS;
75167802Sjkim
76151937Sjkim	ep_ptr = (DAPL_EP *)ep_handle;
77167802Sjkim
7867754Smsmith	/*
7967754Smsmith	 * Verify parameter & state
8067754Smsmith	 */
8167754Smsmith	if (DAPL_BAD_HANDLE(ep_ptr, DAPL_MAGIC_EP)) {
8267754Smsmith		dat_status = DAT_ERROR(DAT_INVALID_HANDLE,
8367754Smsmith		    DAT_INVALID_HANDLE_EP);
8467754Smsmith		goto bail;
8567754Smsmith	}
8667754Smsmith
8767754Smsmith	if (ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED &&
8867754Smsmith	    ep_ptr->param.ep_state != DAT_EP_STATE_DISCONNECTED) {
8967754Smsmith		dat_status = DAT_ERROR(DAT_INVALID_STATE,
9067754Smsmith		    dapls_ep_state_subtype(ep_ptr));
9167754Smsmith		goto bail;
9267754Smsmith	}
9367754Smsmith
9467754Smsmith	if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED) {
9567754Smsmith		dapls_ib_reinit_ep(ep_ptr);
9667754Smsmith		ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
9767754Smsmith	}
9867754Smsmith
99167802Sjkimbail:
10067754Smsmith	return (dat_status);
10167754Smsmith}
102306536Sjkim