1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved. 3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. 4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 5219820Sjeff * 6219820Sjeff * This software is available to you under a choice of one of two 7219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 8219820Sjeff * General Public License (GPL) Version 2, available from the file 9219820Sjeff * COPYING in the main directory of this source tree, or the 10219820Sjeff * OpenIB.org BSD license below: 11219820Sjeff * 12219820Sjeff * Redistribution and use in source and binary forms, with or 13219820Sjeff * without modification, are permitted provided that the following 14219820Sjeff * conditions are met: 15219820Sjeff * 16219820Sjeff * - Redistributions of source code must retain the above 17219820Sjeff * copyright notice, this list of conditions and the following 18219820Sjeff * disclaimer. 19219820Sjeff * 20219820Sjeff * - Redistributions in binary form must reproduce the above 21219820Sjeff * copyright notice, this list of conditions and the following 22219820Sjeff * disclaimer in the documentation and/or other materials 23219820Sjeff * provided with the distribution. 24219820Sjeff * 25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32219820Sjeff * SOFTWARE. 33219820Sjeff * 34219820Sjeff */ 35219820Sjeff 36219820Sjeff/* 37219820Sjeff * Abstract: 38219820Sjeff * Declaration of osm_subn_t. 39219820Sjeff * This object represents an IBA subnet. 40219820Sjeff * This object is part of the OpenSM family of objects. 41219820Sjeff */ 42219820Sjeff 43219820Sjeff#ifndef _OSM_PKT_RANDOMIZER_H_ 44219820Sjeff#define _OSM_PKT_RANDOMIZER_H_ 45219820Sjeff 46219820Sjeff#include <iba/ib_types.h> 47219820Sjeff#include <complib/cl_qmap.h> 48219820Sjeff#include <complib/cl_map.h> 49219820Sjeff#include <complib/cl_ptr_vector.h> 50219820Sjeff#include <complib/cl_list.h> 51219820Sjeff#include <opensm/osm_log.h> 52219820Sjeff#include <opensm/osm_path.h> 53219820Sjeff#include <opensm/osm_madw.h> 54219820Sjeff 55219820Sjeff#ifdef __cplusplus 56219820Sjeff# define BEGIN_C_DECLS extern "C" { 57219820Sjeff# define END_C_DECLS } 58219820Sjeff#else /* !__cplusplus */ 59219820Sjeff# define BEGIN_C_DECLS 60219820Sjeff# define END_C_DECLS 61219820Sjeff#endif /* __cplusplus */ 62219820Sjeff 63219820SjeffBEGIN_C_DECLS 64219820Sjeff/****h* OpenSM/Packet Randomizer 65219820Sjeff* NAME 66219820Sjeff* Packet Randomizer 67219820Sjeff* 68219820Sjeff* DESCRIPTION 69219820Sjeff* The Packet Randomizer object encapsulates the information needed for 70219820Sjeff* randomly dropping packets for debug. 71219820Sjeff* 72219820Sjeff* The Packet Randomizer object is not thread safe, thus callers must 73219820Sjeff* provide serialization. 74219820Sjeff* 75219820Sjeff* AUTHOR 76219820Sjeff* Yael Kalka, Mellanox 77219820Sjeff* 78219820Sjeff*********/ 79219820Sjeff/****d* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_t 80219820Sjeff* NAME 81219820Sjeff* osm_pkt_randomizer_t 82219820Sjeff* 83219820Sjeff* DESCRIPTION 84219820Sjeff* Packet randomizer structure. This structure contains the various 85219820Sjeff* parameters needed by the packet randomizer. 86219820Sjeff* 87219820Sjeff* SYNOPSIS 88219820Sjeff*/ 89219820Sjefftypedef struct _osm_pkt_randomizer { 90219820Sjeff uint8_t osm_pkt_drop_rate; 91219820Sjeff uint8_t osm_pkt_num_unstable_links; 92219820Sjeff uint8_t osm_pkt_unstable_link_rate; 93219820Sjeff osm_dr_path_t *fault_dr_paths; 94219820Sjeff uint8_t num_paths_initialized; 95219820Sjeff} osm_pkt_randomizer_t; 96219820Sjeff 97219820Sjeff/* 98219820Sjeff* FIELDS 99219820Sjeff* 100219820Sjeff* osm_pkt_drop_rate 101219820Sjeff* Used by the randomizer whether to drop a packet or not. 102219820Sjeff* Taken from the global variable OSM_PKT_DROP_RATE. If not given or 103219820Sjeff* if set to zero, the randomizer will not run. 104219820Sjeff* 105219820Sjeff* osm_pkt_num_unstable_links 106219820Sjeff* The number of unstable links to be drawn. 107219820Sjeff* Taken from the global variable OSM_PKT_NUM_UNSTABLE_LINKS. default = 1. 108219820Sjeff* 109219820Sjeff* osm_pkt_unstable_link_rate 110219820Sjeff* Used by the randomizer whether to add a packet to the unstable links 111219820Sjeff* list or not. Taken from the global variable OSM_PKT_UNSTABLE_LINK_RATE. 112219820Sjeff* default = 20. 113219820Sjeff* 114219820Sjeff* fault_dr_path 115219820Sjeff* Array of osm_dr_path_t objects, that includes all the dr_paths 116219820Sjeff* that are marked as errored. 117219820Sjeff* 118219820Sjeff* num_paths_initialized 119219820Sjeff* Describes the number of paths from the fault_dr_paths array that 120219820Sjeff* have already been initialized. 121219820Sjeff* 122219820Sjeff* SEE ALSO 123219820Sjeff* Packet Randomizer object 124219820Sjeff*********/ 125219820Sjeff 126219820Sjeff/****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_init 127219820Sjeff* NAME 128219820Sjeff* osm_pkt_randomizer_init 129219820Sjeff* 130219820Sjeff* DESCRIPTION 131219820Sjeff* The osm_pkt_randomizer_init function initializes the Packet Randomizer object. 132219820Sjeff* 133219820Sjeff* SYNOPSIS 134219820Sjeff*/ 135219820Sjeffib_api_status_t 136219820Sjeffosm_pkt_randomizer_init(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer, 137219820Sjeff IN osm_log_t * p_log); 138219820Sjeff/* 139219820Sjeff* PARAMETERS 140219820Sjeff* p_pkt_randomizer 141219820Sjeff* [in] Pointer to the Packet Randomizer object to be initialized. 142219820Sjeff* 143219820Sjeff* p_log 144219820Sjeff* [in] Pointer to the log object. 145219820Sjeff* 146219820Sjeff* RETURN VALUE 147219820Sjeff* None 148219820Sjeff* 149219820Sjeff* NOTES 150219820Sjeff* 151219820Sjeff* SEE ALSO 152219820Sjeff* 153219820Sjeff*********/ 154219820Sjeff 155219820Sjeff/****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_destroy 156219820Sjeff* NAME 157219820Sjeff* osm_pkt_randomizer_destroy 158219820Sjeff* 159219820Sjeff* DESCRIPTION 160219820Sjeff* The osm_pkt_randomizer_destroy function destroys the Packet Randomizer object. 161219820Sjeff* 162219820Sjeff* SYNOPSIS 163219820Sjeff*/ 164219820Sjeffvoid 165219820Sjeffosm_pkt_randomizer_destroy(IN osm_pkt_randomizer_t ** pp_pkt_randomizer, 166219820Sjeff IN osm_log_t * p_log); 167219820Sjeff/* 168219820Sjeff* PARAMETERS 169219820Sjeff* p_pkt_randomizer 170219820Sjeff* [in] Pointer to the Packet Randomizer object to be destroyed. 171219820Sjeff* 172219820Sjeff* p_log 173219820Sjeff* [in] Pointer to the log object. 174219820Sjeff* 175219820Sjeff* RETURN VALUE 176219820Sjeff* None 177219820Sjeff* 178219820Sjeff* NOTES 179219820Sjeff* 180219820Sjeff* SEE ALSO 181219820Sjeff* 182219820Sjeff*********/ 183219820Sjeff 184219820Sjeff/****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_madw_drop 185219820Sjeff* NAME 186219820Sjeff* osm_pkt_randomizer_madw_drop 187219820Sjeff* 188219820Sjeff* DESCRIPTION 189219820Sjeff* The osm_pkt_randomizer_madw_drop is base function of the packet 190219820Sjeff* randomizer. 191219820Sjeff* It decides according to different random criteria whether or not 192219820Sjeff* the packet received should be dropped (according to its dr_path). 193219820Sjeff* This function is relevant both for mads sent by the SM and mads 194219820Sjeff* received by the SM. 195219820Sjeff* It returns TRUE if the mad should be dropped, and FALSE otherwise. 196219820Sjeff* 197219820Sjeff* SYNOPSIS 198219820Sjeff*/ 199219820Sjeffboolean_t 200219820Sjeffosm_pkt_randomizer_mad_drop(IN osm_log_t * p_log, 201219820Sjeff IN osm_pkt_randomizer_t * p_pkt_randomizer, 202219820Sjeff IN const ib_mad_t * p_mad); 203219820Sjeff/* 204219820Sjeff* PARAMETERS 205219820Sjeff* p_subn 206219820Sjeff* [in] Pointer to the Subnet object for this subnet. 207219820Sjeff* 208219820Sjeff* p_log 209219820Sjeff* [in] Pointer to the log object. 210219820Sjeff* 211219820Sjeff* p_mad 212219820Sjeff* [in] Pointer to the ib_mad_t mad to be checked. 213219820Sjeff* 214219820Sjeff* RETURN VALUE 215219820Sjeff* TRUE if the mad should be dropped. FALSE otherwise. 216219820Sjeff* 217219820Sjeff* NOTES 218219820Sjeff* 219219820Sjeff* SEE ALSO 220219820Sjeff* 221219820Sjeff*********/ 222219820Sjeff 223219820SjeffEND_C_DECLS 224219820Sjeff#endif /* _OSM_PKT_RANDOMIZER_H */ 225