xref: /freebsd/contrib/ofed/opensm/include/opensm/osm_inform.h (revision 87181516ef48be852d5e5fee53c6e0dbfc62f21e)
1 /*
2  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
3  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5  * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
6  *
7  * This software is available to you under a choice of one of two
8  * licenses.  You may choose to be licensed under the terms of the GNU
9  * General Public License (GPL) Version 2, available from the file
10  * COPYING in the main directory of this source tree, or the
11  * OpenIB.org BSD license below:
12  *
13  *     Redistribution and use in source and binary forms, with or
14  *     without modification, are permitted provided that the following
15  *     conditions are met:
16  *
17  *      - Redistributions of source code must retain the above
18  *        copyright notice, this list of conditions and the following
19  *        disclaimer.
20  *
21  *      - Redistributions in binary form must reproduce the above
22  *        copyright notice, this list of conditions and the following
23  *        disclaimer in the documentation and/or other materials
24  *        provided with the distribution.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33  * SOFTWARE.
34  *
35  */
36 
37 /*
38  * Abstract:
39  * 	Declaration of osm_inform_rec_t.
40  *	This object represents an IBA Inform Record.
41  *	This object is part of the OpenSM family of objects.
42  *
43  * Author:
44  *    Eitan Zahavi, Mellanox
45  */
46 
47 #ifndef _OSM_INFR_H_
48 #define _OSM_INFR_H_
49 
50 #include <iba/ib_types.h>
51 #include <complib/cl_qmap.h>
52 #include <complib/cl_spinlock.h>
53 #include <opensm/osm_subnet.h>
54 #include <opensm/osm_madw.h>
55 #include <opensm/osm_log.h>
56 #include <opensm/osm_sa.h>
57 
58 #ifdef __cplusplus
59 #  define BEGIN_C_DECLS extern "C" {
60 #  define END_C_DECLS   }
61 #else				/* !__cplusplus */
62 #  define BEGIN_C_DECLS
63 #  define END_C_DECLS
64 #endif				/* __cplusplus */
65 
66 BEGIN_C_DECLS
67 /****h* OpenSM/Inform Record
68 * NAME
69 *	Inform Record
70 *
71 * DESCRIPTION
72 *	The Inform record encapsulates the information needed by the
73 *	SA to manage InformInfo registrations and sending Reports(Notice)
74 *	when SM receives Traps for registered LIDs.
75 *
76 *	The inform records is not thread safe, thus callers must provide
77 *	serialization.
78 *
79 *	This object should be treated as opaque and should be
80 *	manipulated only through the provided functions.
81 *
82 * AUTHOR
83 *    Eitan Zahavi, Mellanox
84 *
85 *********/
86 /****s* OpenSM: Inform Record/osm_infr_t
87 * NAME
88 *	osm_infr_t
89 *
90 * DESCRIPTION
91 *	Inform Record structure.
92 *
93 *	The osm_infr_t object should be treated as opaque and should
94 *	be manipulated only through the provided functions.
95 *
96 * SYNOPSIS
97 */
98 typedef struct osm_infr {
99 	cl_list_item_t list_item;
100 	osm_bind_handle_t h_bind;
101 	osm_sa_t *sa;
102 	osm_mad_addr_t report_addr;
103 	ib_inform_info_record_t inform_record;
104 } osm_infr_t;
105 /*
106 * FIELDS
107 *	list_item
108 *		List Item for qlist linkage.  Must be first element!!
109 *
110 *	h_bind
111 *		A handle of lower level mad srvc
112 *
113 *	sa
114 *		A pointer to osm_sa object
115 *
116 *	report_addr
117 *		Report address
118 *
119 *	inform_record
120 *		The Inform Info Record
121 *
122 * SEE ALSO
123 *********/
124 
125 /****f* OpenSM: Inform Record/osm_infr_new
126 * NAME
127 *	osm_infr_new
128 *
129 * DESCRIPTION
130 *	Allocates and initializes a Inform Record for use.
131 *
132 * SYNOPSIS
133 */
134 osm_infr_t *osm_infr_new(IN const osm_infr_t * p_infr_rec);
135 /*
136 * PARAMETERS
137 *	p_inf_rec
138 *		[in] Pointer to IB Inform Record
139 *
140 * RETURN VALUES
141 *	pointer to osm_infr_t structure.
142 *
143 * NOTES
144 *	Allows calling other inform record methods.
145 *
146 * SEE ALSO
147 *	Inform Record, osm_infr_delete
148 *********/
149 
150 /****f* OpenSM: Inform Record/osm_infr_delete
151 * NAME
152 *	osm_infr_delete
153 *
154 * DESCRIPTION
155 *	Destroys and deallocates the osm_infr_t structure.
156 *
157 * SYNOPSIS
158 */
159 void osm_infr_delete(IN osm_infr_t * p_infr);
160 /*
161 * PARAMETERS
162 *	p_infr
163 *		[in] Pointer to osm_infr_t structure
164 *
165 * SEE ALSO
166 *	Inform Record, osm_infr_new
167 *********/
168 
169 /****f* OpenSM: Inform Record/osm_infr_get_by_rec
170 * NAME
171 *	osm_infr_get_by_rec
172 *
173 * DESCRIPTION
174 *	Find a matching osm_infr_t in the subnet DB by inform_info_record
175 *
176 * SYNOPSIS
177 */
178 osm_infr_t *osm_infr_get_by_rec(IN osm_subn_t const *p_subn,
179 				IN osm_log_t * p_log,
180 				IN osm_infr_t * p_infr_rec);
181 /*
182 * PARAMETERS
183 *	p_subn
184 *		[in] Pointer to the subnet object
185 *
186 *	p_log
187 *		[in] Pointer to the log object
188 *
189 *	p_inf_rec
190 *		[in] Pointer to an inform_info record
191 *
192 * RETURN
193 *	The matching osm_infr_t
194 * SEE ALSO
195 *	Inform Record, osm_infr_new, osm_infr_delete
196 *********/
197 
198 void osm_infr_insert_to_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
199 			   IN osm_infr_t * p_infr);
200 
201 void osm_infr_remove_from_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
202 			     IN osm_infr_t * p_infr);
203 
204 /****f* OpenSM: Inform Record/osm_infr_remove_subscriptions
205 * NAME
206 *	osm_infr_remove_subscriptions
207 *
208 * DESCRIPTION
209 *	Remove all event subscriptions of a port
210 *
211 * SYNOPSIS
212 */
213 ib_api_status_t
214 osm_infr_remove_subscriptions(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
215 			      IN ib_net64_t port_guid);
216 /*
217 * PARAMETERS
218 *	p_subn
219 *		[in] Pointer to the subnet object
220 *
221 *	p_log
222 *		[in] Pointer to the log object
223 *
224 *	port_guid
225 *		[in] PortGUID of the subscriber that should be removed
226 *
227 * RETURN
228 *	CL_SUCCESS if port_guid had any subscriptions being removed
229 *	CL_NOT_FOUND if port_guid did not have any active subscriptions
230 * SEE ALSO
231 *********/
232 
233 /****f* OpenSM: Inform Record/osm_report_notice
234 * NAME
235 *	osm_report_notice
236 *
237 * DESCRIPTION
238 * Once a Trap was received by the osm_trap_rcv, or a Trap sourced in
239 * the SM was sent (Traps 64-67) this routine is called with a copy of
240 * the notice data.
241 * Given a notice attribute - compare and see if it matches the InformInfo
242 * Element and if it does - call the Report(Notice) for the
243 * target QP registered by the address stored in the InformInfo element
244 *
245 * SYNOPSIS
246 */
247 ib_api_status_t osm_report_notice(IN osm_log_t * p_log, IN osm_subn_t * p_subn,
248 				  IN ib_mad_notice_attr_t * p_ntc);
249 /*
250 * PARAMETERS
251 *	p_rcv
252 *		[in] Pointer to the trap receiver
253 *
254 *	p_ntc
255 *		[in] Pointer to a copy of the incoming trap notice attribute.
256 *
257 * RETURN
258 *	IB_SUCCESS on good completion
259 *
260 * SEE ALSO
261 *	Inform Record, osm_trap_rcv
262 *********/
263 
264 END_C_DECLS
265 #endif				/* _OSM_INFR_H_ */
266