2 * Copyright (c) 2004, 2005 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.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 * Declaration of osm_subn_t.
39 * This object represents an IBA subnet.
40 * This object is part of the OpenSM family of objects.
43 #ifndef _OSM_PKT_RANDOMIZER_H_
44 #define _OSM_PKT_RANDOMIZER_H_
46 #include <iba/ib_types.h>
47 #include <complib/cl_qmap.h>
48 #include <complib/cl_map.h>
49 #include <complib/cl_ptr_vector.h>
50 #include <complib/cl_list.h>
51 #include <opensm/osm_log.h>
52 #include <opensm/osm_path.h>
53 #include <opensm/osm_madw.h>
56 # define BEGIN_C_DECLS extern "C" {
57 # define END_C_DECLS }
58 #else /* !__cplusplus */
59 # define BEGIN_C_DECLS
61 #endif /* __cplusplus */
64 /****h* OpenSM/Packet Randomizer
69 * The Packet Randomizer object encapsulates the information needed for
70 * randomly dropping packets for debug.
72 * The Packet Randomizer object is not thread safe, thus callers must
73 * provide serialization.
76 * Yael Kalka, Mellanox
79 /****d* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_t
81 * osm_pkt_randomizer_t
84 * Packet randomizer structure. This structure contains the various
85 * parameters needed by the packet randomizer.
89 typedef struct _osm_pkt_randomizer {
90 uint8_t osm_pkt_drop_rate;
91 uint8_t osm_pkt_num_unstable_links;
92 uint8_t osm_pkt_unstable_link_rate;
93 osm_dr_path_t *fault_dr_paths;
94 uint8_t num_paths_initialized;
95 } osm_pkt_randomizer_t;
101 * Used by the randomizer whether to drop a packet or not.
102 * Taken from the global variable OSM_PKT_DROP_RATE. If not given or
103 * if set to zero, the randomizer will not run.
105 * osm_pkt_num_unstable_links
106 * The number of unstable links to be drawn.
107 * Taken from the global variable OSM_PKT_NUM_UNSTABLE_LINKS. default = 1.
109 * osm_pkt_unstable_link_rate
110 * Used by the randomizer whether to add a packet to the unstable links
111 * list or not. Taken from the global variable OSM_PKT_UNSTABLE_LINK_RATE.
115 * Array of osm_dr_path_t objects, that includes all the dr_paths
116 * that are marked as errored.
118 * num_paths_initialized
119 * Describes the number of paths from the fault_dr_paths array that
120 * have already been initialized.
123 * Packet Randomizer object
126 /****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_init
128 * osm_pkt_randomizer_init
131 * The osm_pkt_randomizer_init function initializes the Packet Randomizer object.
136 osm_pkt_randomizer_init(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
137 IN osm_log_t * p_log);
141 * [in] Pointer to the Packet Randomizer object to be initialized.
144 * [in] Pointer to the log object.
155 /****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_destroy
157 * osm_pkt_randomizer_destroy
160 * The osm_pkt_randomizer_destroy function destroys the Packet Randomizer object.
165 osm_pkt_randomizer_destroy(IN osm_pkt_randomizer_t ** pp_pkt_randomizer,
166 IN osm_log_t * p_log);
170 * [in] Pointer to the Packet Randomizer object to be destroyed.
173 * [in] Pointer to the log object.
184 /****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_madw_drop
186 * osm_pkt_randomizer_madw_drop
189 * The osm_pkt_randomizer_madw_drop is base function of the packet
191 * It decides according to different random criteria whether or not
192 * the packet received should be dropped (according to its dr_path).
193 * This function is relevant both for mads sent by the SM and mads
194 * received by the SM.
195 * It returns TRUE if the mad should be dropped, and FALSE otherwise.
200 osm_pkt_randomizer_mad_drop(IN osm_log_t * p_log,
201 IN osm_pkt_randomizer_t * p_pkt_randomizer,
202 IN const ib_mad_t * p_mad);
206 * [in] Pointer to the Subnet object for this subnet.
209 * [in] Pointer to the log object.
212 * [in] Pointer to the ib_mad_t mad to be checked.
215 * TRUE if the mad should be dropped. FALSE otherwise.
224 #endif /* _OSM_PKT_RANDOMIZER_H */