Blame include/vendor/osm_vendor_mtl_transaction_mgr.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
 * 	Definition of interface for the MTL Vendor
Packit 13e616
 *	   This object is part of the OpenSM family of objects.
Packit 13e616
 */
Packit 13e616
Packit 13e616
#ifndef _OSM_TRANSACTION_MGR_H_
Packit 13e616
#define _OSM_TRANSACTION_MGR_H_
Packit 13e616
Packit 13e616
  /*
Packit 13e616
     #include <vapi_types.h>
Packit 13e616
     #include <evapi.h>
Packit 13e616
   */
Packit 13e616
Packit 13e616
#include <iba/ib_types.h>
Packit 13e616
#include <iba/ib_al.h>
Packit 13e616
#include <complib/cl_qlist.h>
Packit 13e616
#include <complib/cl_qmap.h>
Packit 13e616
#include <complib/cl_timer.h>
Packit 13e616
#include <complib/cl_thread.h>
Packit 13e616
#include <complib/cl_types_osd.h>
Packit 13e616
#include <complib/cl_spinlock.h>
Packit 13e616
#include <opensm/osm_base.h>
Packit 13e616
#include <opensm/osm_log.h>
Packit 13e616
#include <opensm/osm_madw.h>
Packit 13e616
#ifdef OSM_VENDOR_INTF_MTL
Packit 13e616
#include <ib_mgt.h>
Packit 13e616
#include <opensm/osm_mtl_bind.h>
Packit 13e616
#endif
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
/****s* OpenSM: Transaction Manager/osm_madw_req_t
Packit 13e616
* NAME
Packit 13e616
*  osm_madw_req_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*  The structure defining each object in the transaction_mgr.
Packit 13e616
*  For every request mad sent, we will save such an object for it.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef struct _osm_madw_req {
Packit 13e616
	cl_list_item_t list_item;
Packit 13e616
	cl_map_item_t map_item;
Packit 13e616
	osm_madw_t *p_madw;
Packit 13e616
	uint64_t waking_time;
Packit 13e616
	uint8_t retry_cnt;
Packit 13e616
	osm_bind_handle_t *p_bind;
Packit 13e616
} osm_madw_req_t;
Packit 13e616
Packit 13e616
/*
Packit 13e616
* FIELDS
Packit 13e616
*  list_item
Packit 13e616
*     List item for qlist linkage. Must be first element!!
Packit 13e616
*
Packit 13e616
*  map_item
Packit 13e616
*     Map item for qmap linkage.
Packit 13e616
*
Packit 13e616
*  p_madw
Packit 13e616
*     pointer to mad wrapper that is expecting to get a response.
Packit 13e616
*
Packit 13e616
*  waking_time
Packit 13e616
*     Time stamp (in microseconds) when the p_madw needs to wake up.
Packit 13e616
*     This value is
Packit 13e616
*      cl_get_time_stamp() + timeout  during the sending of the mad.
Packit 13e616
*      where timeout should be given in microseconds.
Packit 13e616
*
Packit 13e616
*  retry_cnt
Packit 13e616
*     The number of outstanding retries to be called.
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****s* OpenSM: Transaction Manager/osm_transaction_mgr_t
Packit 13e616
* NAME
Packit 13e616
*  osm_transaction_mgr_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*  This structure defines the transaction manager.
Packit 13e616
*  It holds a qlist and a qmap, a lock on the transaction manager, and
Packit 13e616
*  a timer used for the list.
Packit 13e616
*  The manager is responsible for keeping track of every request mad that was
Packit 13e616
*  sent. It is used for finding mads according to their transaction id, and for
Packit 13e616
*  acting as an event wheel - reporting as error each packet was supposed to get
Packit 13e616
*  a response and didn't get one by the timeout time expected.
Packit 13e616
*
Packit 13e616
*  Both the list and the map hold the osm_madw_req_t objects - one for every madw.
Packit 13e616
*
Packit 13e616
*  Managing of the list:
Packit 13e616
*  The timer wakes on the timeout of the first madw. If the waking_time is greater than
Packit 13e616
*  the current time - then the mad received a response. If not - the mad didn't get
Packit 13e616
*  its response.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef struct _osm_transaction_mgr {
Packit 13e616
	cl_qmap_t *madw_by_tid_map_p;
Packit 13e616
	cl_qlist_t *madw_reqs_list_p;
Packit 13e616
	cl_spinlock_t transaction_mgr_lock;
Packit 13e616
	cl_timer_t madw_list_timer;
Packit 13e616
} osm_transaction_mgr_t;
Packit 13e616
Packit 13e616
/*
Packit 13e616
* FIELDS
Packit 13e616
*  madw_by_tid_map_p
Packit 13e616
*     A qmap with key = transaction id. and value of osm_madw_req_t.
Packit 13e616
*
Packit 13e616
*  madw_reqs_list_p
Packit 13e616
*     A qlist of all the madw with their waking time.
Packit 13e616
*
Packit 13e616
*  transaction_mgr_lock
Packit 13e616
*     Lock used on the transaction manager - make sure changes on it are serial.
Packit 13e616
*
Packit 13e616
*  madw_list_timer
Packit 13e616
*     Timer on the list.
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Transaction Manager/osm_transaction_mgr_init
Packit 13e616
* NAME
Packit 13e616
*	osm_transaction_mgr_init
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Initialize the transaction manager.
Packit 13e616
*  Will update the p_transaction_mgr in the vendor object with
Packit 13e616
*  the new Transaction Manager created.*
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void osm_transaction_mgr_init(IN osm_vendor_t * const p_vend);
Packit 13e616
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_vend
Packit 13e616
*		[in] Pointer to a Osm Vendor object.
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Transaction Manager/osm_transaction_mgr_destroy
Packit 13e616
* NAME
Packit 13e616
*	osm_transaction_mgr_destroy
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Destroy the transaction manager.
Packit 13e616
*  Will de-allocate all memory allocated by the Transaction
Packit 13e616
*  Manager up to now.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void osm_transaction_mgr_destroy(IN osm_vendor_t * const p_vend);
Packit 13e616
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_vend
Packit 13e616
*		[in] Pointer to a Osm Vendor object.
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Transaction Manager/osm_transaction_mgr_insert_madw
Packit 13e616
* NAME
Packit 13e616
*	osm_transaction_mgr_insert_madw
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Insert a new madw to the manager. The madw is added with a waking_time,
Packit 13e616
*  Which is equal to the current_time + timeout. This is the maximum time
Packit 13e616
*  that the madw can leave without being handled (e.g - get a response).
Packit 13e616
*  If there are no madw saved in the manager - start the timer for vendor
Packit 13e616
*  timeout period.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
ib_api_status_t
Packit 13e616
osm_transaction_mgr_insert_madw(IN osm_bind_handle_t * p_bind,
Packit 13e616
				IN osm_madw_t * p_madw);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_vend
Packit 13e616
*		[in] Pointer to a mtl bind object.
Packit 13e616
*
Packit 13e616
*  p_madw
Packit 13e616
*     [in] Pointer to the Mad Wrapper to be added.
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Transaction Manager/osm_transaction_mgr_erase_madw
Packit 13e616
* NAME
Packit 13e616
*	osm_transaction_mgr_erase_madw
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Erase a madw object from the manager.
Packit 13e616
*  The removal is done using the transaction id of the mad - using
Packit 13e616
*  it the madw_p is allocated (in the qmap) and removed from the
Packit 13e616
*  qmap and qlist.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
ib_api_status_t
Packit 13e616
osm_transaction_mgr_erase_madw(IN osm_vendor_t * const p_vend,
Packit 13e616
			       IN ib_mad_t * p_mad);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_vend
Packit 13e616
*		[in] Pointer to a Osm Vendor object.
Packit 13e616
*
Packit 13e616
*  p_mad
Packit 13e616
*      [in] Pointer to the Mad to be removed.
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Transaction Manager/osm_transaction_mgr_get_madw_for_tid
Packit 13e616
* NAME
Packit 13e616
*	osm_transaction_mgr_get_madw_for_tid
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Return the mad wrapper, given the p_mad (and in it the transaction id)
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
ib_api_status_t
Packit 13e616
osm_transaction_mgr_get_madw_for_tid(IN osm_vendor_t * const p_vend,
Packit 13e616
				     IN ib_mad_t * const p_mad,
Packit 13e616
				     OUT osm_madw_t ** req_madw_p);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_vend
Packit 13e616
*		[in] Pointer to a Osm Vendor object.
Packit 13e616
*
Packit 13e616
*  p_mad
Packit 13e616
*      [in] Pointer to the Mad to be located.
Packit 13e616
*
Packit 13e616
* req_madw_p
Packit 13e616
*      [out] Pointer to the mad Wrapper to be found.
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Transaction Manager/osm_transaction_mgr_callback
Packit 13e616
* NAME
Packit 13e616
*	osm_transaction_mgr_callback
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This callback is called on timeout of the timer.
Packit 13e616
*  It checks the time of the head madw in the qlist, and compares it to
Packit 13e616
*  the current time.
Packit 13e616
*  Will send an error callback if the time of the madw is less than the
Packit 13e616
*  current time - this means that the madw wasn't removed in the timeout
Packit 13e616
*  it was supposed to be handled.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void osm_transaction_mgr_callback(IN void *context);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	context
Packit 13e616
*		[in] void* context
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
END_C_DECLS
Packit 13e616
#endif				/* _OSM_TRANSACTION_MGR_H_ */