Blame include/vendor/osm_pkt_randomizer.h

Packit 13e616
/*
Packit 13e616
 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
Packit 13e616
 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
Packit 13e616
 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
Packit 13e616
 *
Packit 13e616
 * This software is available to you under a choice of one of two
Packit 13e616
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 13e616
 * General Public License (GPL) Version 2, available from the file
Packit 13e616
 * COPYING in the main directory of this source tree, or the
Packit 13e616
 * OpenIB.org BSD license below:
Packit 13e616
 *
Packit 13e616
 *     Redistribution and use in source and binary forms, with or
Packit 13e616
 *     without modification, are permitted provided that the following
Packit 13e616
 *     conditions are met:
Packit 13e616
 *
Packit 13e616
 *      - Redistributions of source code must retain the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer.
Packit 13e616
 *
Packit 13e616
 *      - Redistributions in binary form must reproduce the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer in the documentation and/or other materials
Packit 13e616
 *        provided with the distribution.
Packit 13e616
 *
Packit 13e616
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 13e616
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 13e616
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 13e616
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 13e616
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 13e616
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 13e616
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 13e616
 * SOFTWARE.
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
/*
Packit 13e616
 * Abstract:
Packit 13e616
 * 	Declaration of osm_subn_t.
Packit 13e616
 *	This object represents an IBA subnet.
Packit 13e616
 *	This object is part of the OpenSM family of objects.
Packit 13e616
 */
Packit 13e616
Packit 13e616
#ifndef _OSM_PKT_RANDOMIZER_H_
Packit 13e616
#define _OSM_PKT_RANDOMIZER_H_
Packit 13e616
Packit 13e616
#include <iba/ib_types.h>
Packit 13e616
#include <complib/cl_qmap.h>
Packit 13e616
#include <complib/cl_map.h>
Packit 13e616
#include <complib/cl_ptr_vector.h>
Packit 13e616
#include <complib/cl_list.h>
Packit 13e616
#include <opensm/osm_log.h>
Packit 13e616
#include <opensm/osm_path.h>
Packit 13e616
#include <opensm/osm_madw.h>
Packit 13e616
Packit 13e616
#ifdef __cplusplus
Packit 13e616
#  define BEGIN_C_DECLS extern "C" {
Packit 13e616
#  define END_C_DECLS   }
Packit 13e616
#else				/* !__cplusplus */
Packit 13e616
#  define BEGIN_C_DECLS
Packit 13e616
#  define END_C_DECLS
Packit 13e616
#endif				/* __cplusplus */
Packit 13e616
Packit 13e616
BEGIN_C_DECLS
Packit 13e616
/****h* OpenSM/Packet Randomizer
Packit 13e616
* NAME
Packit 13e616
*	Packet Randomizer
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The Packet Randomizer object encapsulates the information needed for
Packit 13e616
*	randomly dropping packets for debug.
Packit 13e616
*
Packit 13e616
*	The Packet Randomizer object is not thread safe, thus callers must
Packit 13e616
*	provide serialization.
Packit 13e616
*
Packit 13e616
* AUTHOR
Packit 13e616
*	Yael Kalka, Mellanox
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
/****d* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_t
Packit 13e616
* NAME
Packit 13e616
*	osm_pkt_randomizer_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Packet randomizer structure. This structure contains the various
Packit 13e616
*  parameters needed by the packet randomizer.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef struct _osm_pkt_randomizer {
Packit 13e616
	uint8_t osm_pkt_drop_rate;
Packit 13e616
	uint8_t osm_pkt_num_unstable_links;
Packit 13e616
	uint8_t osm_pkt_unstable_link_rate;
Packit 13e616
	osm_dr_path_t *fault_dr_paths;
Packit 13e616
	uint8_t num_paths_initialized;
Packit 13e616
} osm_pkt_randomizer_t;
Packit 13e616
Packit 13e616
/*
Packit 13e616
* FIELDS
Packit 13e616
*
Packit 13e616
*  osm_pkt_drop_rate
Packit 13e616
*     Used by the randomizer whether to drop a packet or not.
Packit 13e616
*     Taken from the global variable OSM_PKT_DROP_RATE. If not given or
Packit 13e616
*     if set to zero, the randomizer will not run.
Packit 13e616
*
Packit 13e616
*  osm_pkt_num_unstable_links
Packit 13e616
*     The number of unstable links to be drawn.
Packit 13e616
*     Taken from the global variable OSM_PKT_NUM_UNSTABLE_LINKS. default = 1.
Packit 13e616
*
Packit 13e616
*  osm_pkt_unstable_link_rate
Packit 13e616
*     Used by the randomizer whether to add a packet to the unstable links
Packit 13e616
*     list or not. Taken from the global variable OSM_PKT_UNSTABLE_LINK_RATE.
Packit 13e616
*     default = 20.
Packit 13e616
*
Packit 13e616
*	fault_dr_path
Packit 13e616
*		Array of osm_dr_path_t objects, that includes all the dr_paths
Packit 13e616
*     that are marked as errored.
Packit 13e616
*
Packit 13e616
*  num_paths_initialized
Packit 13e616
*     Describes the number of paths from the fault_dr_paths array that
Packit 13e616
*     have already been initialized.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Packet Randomizer object
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_init
Packit 13e616
* NAME
Packit 13e616
*	osm_pkt_randomizer_init
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The osm_pkt_randomizer_init function initializes the Packet Randomizer object.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
ib_api_status_t
Packit 13e616
osm_pkt_randomizer_init(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
Packit 13e616
			IN osm_log_t * p_log);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*  p_pkt_randomizer
Packit 13e616
*     [in] Pointer to the Packet Randomizer object to be initialized.
Packit 13e616
*
Packit 13e616
*	p_log
Packit 13e616
*		[in] Pointer to the log object.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	None
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_destroy
Packit 13e616
* NAME
Packit 13e616
*	osm_pkt_randomizer_destroy
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The osm_pkt_randomizer_destroy function destroys the Packet Randomizer object.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void
Packit 13e616
osm_pkt_randomizer_destroy(IN osm_pkt_randomizer_t ** pp_pkt_randomizer,
Packit 13e616
			   IN osm_log_t * p_log);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*  p_pkt_randomizer
Packit 13e616
*     [in] Pointer to the Packet Randomizer object to be destroyed.
Packit 13e616
*
Packit 13e616
*	p_log
Packit 13e616
*		[in] Pointer to the log object.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	None
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Pkt_Randomizer/osm_pkt_randomizer_madw_drop
Packit 13e616
* NAME
Packit 13e616
*	osm_pkt_randomizer_madw_drop
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The osm_pkt_randomizer_madw_drop is base function of the packet
Packit 13e616
*  randomizer.
Packit 13e616
*  It decides according to different random criteria whether or not
Packit 13e616
*  the packet received should be dropped (according to its dr_path).
Packit 13e616
*  This function is relevant both for mads sent by the SM and mads
Packit 13e616
*  received by the SM.
Packit 13e616
*  It returns TRUE if the mad should be dropped, and FALSE otherwise.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
boolean_t
Packit 13e616
osm_pkt_randomizer_mad_drop(IN osm_log_t * p_log,
Packit 13e616
			    IN osm_pkt_randomizer_t * p_pkt_randomizer,
Packit 13e616
			    IN const ib_mad_t * p_mad);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*  p_subn
Packit 13e616
*     [in] Pointer to the Subnet object for this subnet.
Packit 13e616
*
Packit 13e616
*	p_log
Packit 13e616
*		[in] Pointer to the log object.
Packit 13e616
*
Packit 13e616
*  p_mad
Packit 13e616
*     [in] Pointer to the ib_mad_t mad to be checked.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	TRUE if the mad should be dropped. FALSE otherwise.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
END_C_DECLS
Packit 13e616
#endif				/* _OSM_PKT_RANDOMIZER_H */