xref: /illumos-gate/usr/src/lib/udapl/udapl_tavor/common/dapl_ep_reset.c (revision 9e39c5ba00a55fa05777cc94b148296af305e135)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
24  */
25 
26 /*
27  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 /*
32  *
33  * MODULE: dapl_ep_reset.c
34  *
35  * PURPOSE: Endpoint management
36  * Description: Interfaces in this file are completely described in
37  *		the DAPL 1.1 API, Chapter 6, section 5.13
38  *
39  * $Id: dapl_ep_reset.c,v 1.6 2003/07/08 14:23:35 sjs2 Exp $
40  */
41 
42 #include "dapl.h"
43 #include "dapl_ia_util.h"
44 #include "dapl_ep_util.h"
45 #include "dapl_adapter_util.h"
46 #include "dapl_ring_buffer_util.h"
47 
48 /*
49  * dapl_ep_reset
50  *
51  * DAPL Requirements Version 1.1, 6.5.13
52  *
53  * Reset the QP attached to this Endpoint, transitioning back to the
54  * INIT state
55  *
56  * Input:
57  *	ep_handle
58  *
59  * Output:
60  *	none
61  *
62  * Returns:
63  *	DAT_SUCCESS
64  *	DAT_INVALID_PARAMETER
65  *	DAT_INVALID_STATE
66  */
67 DAT_RETURN
dapl_ep_reset(IN DAT_EP_HANDLE ep_handle)68 dapl_ep_reset(
69 	IN DAT_EP_HANDLE ep_handle)
70 {
71 	DAPL_EP	*ep_ptr;
72 	DAT_RETURN dat_status;
73 
74 	dat_status = DAT_SUCCESS;
75 
76 	ep_ptr = (DAPL_EP *)ep_handle;
77 
78 	/*
79 	 * Verify parameter & state
80 	 */
81 	if (DAPL_BAD_HANDLE(ep_ptr, DAPL_MAGIC_EP)) {
82 		dat_status = DAT_ERROR(DAT_INVALID_HANDLE,
83 		    DAT_INVALID_HANDLE_EP);
84 		goto bail;
85 	}
86 
87 	if (ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED &&
88 	    ep_ptr->param.ep_state != DAT_EP_STATE_DISCONNECTED) {
89 		dat_status = DAT_ERROR(DAT_INVALID_STATE,
90 		    dapls_ep_state_subtype(ep_ptr));
91 		goto bail;
92 	}
93 
94 	if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED) {
95 		dapls_ib_reinit_ep(ep_ptr);
96 		ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
97 	}
98 
99 bail:
100 	return (dat_status);
101 }
102