xref: /freebsd/contrib/ofed/opensm/include/vendor/osm_pkt_randomizer.h (revision 87181516ef48be852d5e5fee53c6e0dbfc62f21e)
1*d6b92ffaSHans Petter Selasky /*
2*d6b92ffaSHans Petter Selasky  * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3*d6b92ffaSHans Petter Selasky  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4*d6b92ffaSHans Petter Selasky  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5*d6b92ffaSHans Petter Selasky  *
6*d6b92ffaSHans Petter Selasky  * This software is available to you under a choice of one of two
7*d6b92ffaSHans Petter Selasky  * licenses.  You may choose to be licensed under the terms of the GNU
8*d6b92ffaSHans Petter Selasky  * General Public License (GPL) Version 2, available from the file
9*d6b92ffaSHans Petter Selasky  * COPYING in the main directory of this source tree, or the
10*d6b92ffaSHans Petter Selasky  * OpenIB.org BSD license below:
11*d6b92ffaSHans Petter Selasky  *
12*d6b92ffaSHans Petter Selasky  *     Redistribution and use in source and binary forms, with or
13*d6b92ffaSHans Petter Selasky  *     without modification, are permitted provided that the following
14*d6b92ffaSHans Petter Selasky  *     conditions are met:
15*d6b92ffaSHans Petter Selasky  *
16*d6b92ffaSHans Petter Selasky  *      - Redistributions of source code must retain the above
17*d6b92ffaSHans Petter Selasky  *        copyright notice, this list of conditions and the following
18*d6b92ffaSHans Petter Selasky  *        disclaimer.
19*d6b92ffaSHans Petter Selasky  *
20*d6b92ffaSHans Petter Selasky  *      - Redistributions in binary form must reproduce the above
21*d6b92ffaSHans Petter Selasky  *        copyright notice, this list of conditions and the following
22*d6b92ffaSHans Petter Selasky  *        disclaimer in the documentation and/or other materials
23*d6b92ffaSHans Petter Selasky  *        provided with the distribution.
24*d6b92ffaSHans Petter Selasky  *
25*d6b92ffaSHans Petter Selasky  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26*d6b92ffaSHans Petter Selasky  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27*d6b92ffaSHans Petter Selasky  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28*d6b92ffaSHans Petter Selasky  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29*d6b92ffaSHans Petter Selasky  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30*d6b92ffaSHans Petter Selasky  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31*d6b92ffaSHans Petter Selasky  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32*d6b92ffaSHans Petter Selasky  * SOFTWARE.
33*d6b92ffaSHans Petter Selasky  *
34*d6b92ffaSHans Petter Selasky  */
35*d6b92ffaSHans Petter Selasky 
36*d6b92ffaSHans Petter Selasky /*
37*d6b92ffaSHans Petter Selasky  * Abstract:
38*d6b92ffaSHans Petter Selasky  * 	Declaration of osm_subn_t.
39*d6b92ffaSHans Petter Selasky  *	This object represents an IBA subnet.
40*d6b92ffaSHans Petter Selasky  *	This object is part of the OpenSM family of objects.
41*d6b92ffaSHans Petter Selasky  */
42*d6b92ffaSHans Petter Selasky 
43*d6b92ffaSHans Petter Selasky #ifndef _OSM_PKT_RANDOMIZER_H_
44*d6b92ffaSHans Petter Selasky #define _OSM_PKT_RANDOMIZER_H_
45*d6b92ffaSHans Petter Selasky 
46*d6b92ffaSHans Petter Selasky #include <iba/ib_types.h>
47*d6b92ffaSHans Petter Selasky #include <complib/cl_qmap.h>
48*d6b92ffaSHans Petter Selasky #include <complib/cl_map.h>
49*d6b92ffaSHans Petter Selasky #include <complib/cl_ptr_vector.h>
50*d6b92ffaSHans Petter Selasky #include <complib/cl_list.h>
51*d6b92ffaSHans Petter Selasky #include <opensm/osm_log.h>
52*d6b92ffaSHans Petter Selasky #include <opensm/osm_path.h>
53*d6b92ffaSHans Petter Selasky #include <opensm/osm_madw.h>
54*d6b92ffaSHans Petter Selasky 
55*d6b92ffaSHans Petter Selasky #ifdef __cplusplus
56*d6b92ffaSHans Petter Selasky #  define BEGIN_C_DECLS extern "C" {
57*d6b92ffaSHans Petter Selasky #  define END_C_DECLS   }
58*d6b92ffaSHans Petter Selasky #else				/* !__cplusplus */
59*d6b92ffaSHans Petter Selasky #  define BEGIN_C_DECLS
60*d6b92ffaSHans Petter Selasky #  define END_C_DECLS
61*d6b92ffaSHans Petter Selasky #endif				/* __cplusplus */
62*d6b92ffaSHans Petter Selasky 
63*d6b92ffaSHans Petter Selasky BEGIN_C_DECLS
64*d6b92ffaSHans Petter Selasky /****h* OpenSM/Packet Randomizer
65*d6b92ffaSHans Petter Selasky * NAME
66*d6b92ffaSHans Petter Selasky *	Packet Randomizer
67*d6b92ffaSHans Petter Selasky *
68*d6b92ffaSHans Petter Selasky * DESCRIPTION
69*d6b92ffaSHans Petter Selasky *	The Packet Randomizer object encapsulates the information needed for
70*d6b92ffaSHans Petter Selasky *	randomly dropping packets for debug.
71*d6b92ffaSHans Petter Selasky *
72*d6b92ffaSHans Petter Selasky *	The Packet Randomizer object is not thread safe, thus callers must
73*d6b92ffaSHans Petter Selasky *	provide serialization.
74*d6b92ffaSHans Petter Selasky *
75*d6b92ffaSHans Petter Selasky * AUTHOR
76*d6b92ffaSHans Petter Selasky *	Yael Kalka, Mellanox
77*d6b92ffaSHans Petter Selasky *
78*d6b92ffaSHans Petter Selasky *********/
79*d6b92ffaSHans Petter Selasky /****d* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_t
80*d6b92ffaSHans Petter Selasky * NAME
81*d6b92ffaSHans Petter Selasky *	osm_pkt_randomizer_t
82*d6b92ffaSHans Petter Selasky *
83*d6b92ffaSHans Petter Selasky * DESCRIPTION
84*d6b92ffaSHans Petter Selasky *	Packet randomizer structure. This structure contains the various
85*d6b92ffaSHans Petter Selasky *  parameters needed by the packet randomizer.
86*d6b92ffaSHans Petter Selasky *
87*d6b92ffaSHans Petter Selasky * SYNOPSIS
88*d6b92ffaSHans Petter Selasky */
89*d6b92ffaSHans Petter Selasky typedef struct _osm_pkt_randomizer {
90*d6b92ffaSHans Petter Selasky 	uint8_t osm_pkt_drop_rate;
91*d6b92ffaSHans Petter Selasky 	uint8_t osm_pkt_num_unstable_links;
92*d6b92ffaSHans Petter Selasky 	uint8_t osm_pkt_unstable_link_rate;
93*d6b92ffaSHans Petter Selasky 	osm_dr_path_t *fault_dr_paths;
94*d6b92ffaSHans Petter Selasky 	uint8_t num_paths_initialized;
95*d6b92ffaSHans Petter Selasky } osm_pkt_randomizer_t;
96*d6b92ffaSHans Petter Selasky 
97*d6b92ffaSHans Petter Selasky /*
98*d6b92ffaSHans Petter Selasky * FIELDS
99*d6b92ffaSHans Petter Selasky *
100*d6b92ffaSHans Petter Selasky *  osm_pkt_drop_rate
101*d6b92ffaSHans Petter Selasky *     Used by the randomizer whether to drop a packet or not.
102*d6b92ffaSHans Petter Selasky *     Taken from the global variable OSM_PKT_DROP_RATE. If not given or
103*d6b92ffaSHans Petter Selasky *     if set to zero, the randomizer will not run.
104*d6b92ffaSHans Petter Selasky *
105*d6b92ffaSHans Petter Selasky *  osm_pkt_num_unstable_links
106*d6b92ffaSHans Petter Selasky *     The number of unstable links to be drawn.
107*d6b92ffaSHans Petter Selasky *     Taken from the global variable OSM_PKT_NUM_UNSTABLE_LINKS. default = 1.
108*d6b92ffaSHans Petter Selasky *
109*d6b92ffaSHans Petter Selasky *  osm_pkt_unstable_link_rate
110*d6b92ffaSHans Petter Selasky *     Used by the randomizer whether to add a packet to the unstable links
111*d6b92ffaSHans Petter Selasky *     list or not. Taken from the global variable OSM_PKT_UNSTABLE_LINK_RATE.
112*d6b92ffaSHans Petter Selasky *     default = 20.
113*d6b92ffaSHans Petter Selasky *
114*d6b92ffaSHans Petter Selasky *	fault_dr_path
115*d6b92ffaSHans Petter Selasky *		Array of osm_dr_path_t objects, that includes all the dr_paths
116*d6b92ffaSHans Petter Selasky *     that are marked as errored.
117*d6b92ffaSHans Petter Selasky *
118*d6b92ffaSHans Petter Selasky *  num_paths_initialized
119*d6b92ffaSHans Petter Selasky *     Describes the number of paths from the fault_dr_paths array that
120*d6b92ffaSHans Petter Selasky *     have already been initialized.
121*d6b92ffaSHans Petter Selasky *
122*d6b92ffaSHans Petter Selasky * SEE ALSO
123*d6b92ffaSHans Petter Selasky *	Packet Randomizer object
124*d6b92ffaSHans Petter Selasky *********/
125*d6b92ffaSHans Petter Selasky 
126*d6b92ffaSHans Petter Selasky /****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_init
127*d6b92ffaSHans Petter Selasky * NAME
128*d6b92ffaSHans Petter Selasky *	osm_pkt_randomizer_init
129*d6b92ffaSHans Petter Selasky *
130*d6b92ffaSHans Petter Selasky * DESCRIPTION
131*d6b92ffaSHans Petter Selasky *	The osm_pkt_randomizer_init function initializes the Packet Randomizer object.
132*d6b92ffaSHans Petter Selasky *
133*d6b92ffaSHans Petter Selasky * SYNOPSIS
134*d6b92ffaSHans Petter Selasky */
135*d6b92ffaSHans Petter Selasky ib_api_status_t
136*d6b92ffaSHans Petter Selasky osm_pkt_randomizer_init(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
137*d6b92ffaSHans Petter Selasky 			IN osm_log_t * p_log);
138*d6b92ffaSHans Petter Selasky /*
139*d6b92ffaSHans Petter Selasky * PARAMETERS
140*d6b92ffaSHans Petter Selasky *  p_pkt_randomizer
141*d6b92ffaSHans Petter Selasky *     [in] Pointer to the Packet Randomizer object to be initialized.
142*d6b92ffaSHans Petter Selasky *
143*d6b92ffaSHans Petter Selasky *	p_log
144*d6b92ffaSHans Petter Selasky *		[in] Pointer to the log object.
145*d6b92ffaSHans Petter Selasky *
146*d6b92ffaSHans Petter Selasky * RETURN VALUE
147*d6b92ffaSHans Petter Selasky *	None
148*d6b92ffaSHans Petter Selasky *
149*d6b92ffaSHans Petter Selasky * NOTES
150*d6b92ffaSHans Petter Selasky *
151*d6b92ffaSHans Petter Selasky * SEE ALSO
152*d6b92ffaSHans Petter Selasky *
153*d6b92ffaSHans Petter Selasky *********/
154*d6b92ffaSHans Petter Selasky 
155*d6b92ffaSHans Petter Selasky /****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_destroy
156*d6b92ffaSHans Petter Selasky * NAME
157*d6b92ffaSHans Petter Selasky *	osm_pkt_randomizer_destroy
158*d6b92ffaSHans Petter Selasky *
159*d6b92ffaSHans Petter Selasky * DESCRIPTION
160*d6b92ffaSHans Petter Selasky *	The osm_pkt_randomizer_destroy function destroys the Packet Randomizer object.
161*d6b92ffaSHans Petter Selasky *
162*d6b92ffaSHans Petter Selasky * SYNOPSIS
163*d6b92ffaSHans Petter Selasky */
164*d6b92ffaSHans Petter Selasky void
165*d6b92ffaSHans Petter Selasky osm_pkt_randomizer_destroy(IN osm_pkt_randomizer_t ** pp_pkt_randomizer,
166*d6b92ffaSHans Petter Selasky 			   IN osm_log_t * p_log);
167*d6b92ffaSHans Petter Selasky /*
168*d6b92ffaSHans Petter Selasky * PARAMETERS
169*d6b92ffaSHans Petter Selasky *  p_pkt_randomizer
170*d6b92ffaSHans Petter Selasky *     [in] Pointer to the Packet Randomizer object to be destroyed.
171*d6b92ffaSHans Petter Selasky *
172*d6b92ffaSHans Petter Selasky *	p_log
173*d6b92ffaSHans Petter Selasky *		[in] Pointer to the log object.
174*d6b92ffaSHans Petter Selasky *
175*d6b92ffaSHans Petter Selasky * RETURN VALUE
176*d6b92ffaSHans Petter Selasky *	None
177*d6b92ffaSHans Petter Selasky *
178*d6b92ffaSHans Petter Selasky * NOTES
179*d6b92ffaSHans Petter Selasky *
180*d6b92ffaSHans Petter Selasky * SEE ALSO
181*d6b92ffaSHans Petter Selasky *
182*d6b92ffaSHans Petter Selasky *********/
183*d6b92ffaSHans Petter Selasky 
184*d6b92ffaSHans Petter Selasky /****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_madw_drop
185*d6b92ffaSHans Petter Selasky * NAME
186*d6b92ffaSHans Petter Selasky *	osm_pkt_randomizer_madw_drop
187*d6b92ffaSHans Petter Selasky *
188*d6b92ffaSHans Petter Selasky * DESCRIPTION
189*d6b92ffaSHans Petter Selasky *	The osm_pkt_randomizer_madw_drop is base function of the packet
190*d6b92ffaSHans Petter Selasky *  randomizer.
191*d6b92ffaSHans Petter Selasky *  It decides according to different random criteria whether or not
192*d6b92ffaSHans Petter Selasky *  the packet received should be dropped (according to its dr_path).
193*d6b92ffaSHans Petter Selasky *  This function is relevant both for mads sent by the SM and mads
194*d6b92ffaSHans Petter Selasky *  received by the SM.
195*d6b92ffaSHans Petter Selasky *  It returns TRUE if the mad should be dropped, and FALSE otherwise.
196*d6b92ffaSHans Petter Selasky *
197*d6b92ffaSHans Petter Selasky * SYNOPSIS
198*d6b92ffaSHans Petter Selasky */
199*d6b92ffaSHans Petter Selasky boolean_t
200*d6b92ffaSHans Petter Selasky osm_pkt_randomizer_mad_drop(IN osm_log_t * p_log,
201*d6b92ffaSHans Petter Selasky 			    IN osm_pkt_randomizer_t * p_pkt_randomizer,
202*d6b92ffaSHans Petter Selasky 			    IN const ib_mad_t * p_mad);
203*d6b92ffaSHans Petter Selasky /*
204*d6b92ffaSHans Petter Selasky * PARAMETERS
205*d6b92ffaSHans Petter Selasky *  p_subn
206*d6b92ffaSHans Petter Selasky *     [in] Pointer to the Subnet object for this subnet.
207*d6b92ffaSHans Petter Selasky *
208*d6b92ffaSHans Petter Selasky *	p_log
209*d6b92ffaSHans Petter Selasky *		[in] Pointer to the log object.
210*d6b92ffaSHans Petter Selasky *
211*d6b92ffaSHans Petter Selasky *  p_mad
212*d6b92ffaSHans Petter Selasky *     [in] Pointer to the ib_mad_t mad to be checked.
213*d6b92ffaSHans Petter Selasky *
214*d6b92ffaSHans Petter Selasky * RETURN VALUE
215*d6b92ffaSHans Petter Selasky *	TRUE if the mad should be dropped. FALSE otherwise.
216*d6b92ffaSHans Petter Selasky *
217*d6b92ffaSHans Petter Selasky * NOTES
218*d6b92ffaSHans Petter Selasky *
219*d6b92ffaSHans Petter Selasky * SEE ALSO
220*d6b92ffaSHans Petter Selasky *
221*d6b92ffaSHans Petter Selasky *********/
222*d6b92ffaSHans Petter Selasky 
223*d6b92ffaSHans Petter Selasky END_C_DECLS
224*d6b92ffaSHans Petter Selasky #endif				/* _OSM_PKT_RANDOMIZER_H */
225