Blame IbAccess/Common/Ibt/Gsa/gsamain.h

Packit 857059
/* BEGIN_ICS_COPYRIGHT4 ****************************************
Packit 857059
Packit 857059
Copyright (c) 2015-2017, Intel Corporation
Packit 857059
Packit 857059
Redistribution and use in source and binary forms, with or without
Packit 857059
modification, are permitted provided that the following conditions are met:
Packit 857059
Packit 857059
    * Redistributions of source code must retain the above copyright notice,
Packit 857059
      this list of conditions and the following disclaimer.
Packit 857059
    * Redistributions in binary form must reproduce the above copyright
Packit 857059
      notice, this list of conditions and the following disclaimer in the
Packit 857059
      documentation and/or other materials provided with the distribution.
Packit 857059
    * Neither the name of Intel Corporation nor the names of its contributors
Packit 857059
      may be used to endorse or promote products derived from this software
Packit 857059
      without specific prior written permission.
Packit 857059
Packit 857059
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 857059
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 857059
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit 857059
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit 857059
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 857059
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit 857059
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit 857059
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit 857059
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 857059
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 857059
Packit 857059
** END_ICS_COPYRIGHT4   ****************************************/
Packit 857059
/* [ICS VERSION STRING: unknown] */
Packit 857059
Packit 857059
#ifndef _IBA_IB_GSA_MAIN_H_
Packit 857059
#define _IBA_IB_GSA_MAIN_H_
Packit 857059
Packit 857059
Packit 857059
#include "datatypes.h"
Packit 857059
#include "stl_types.h"
Packit 857059
#include "stl_mad_priv.h"
Packit 857059
#include "vpi.h"
Packit 857059
#include "sma_osd.h"
Packit 857059
#include "ib_debug_osd.h"
Packit 857059
#include "vpi_export.h"
Packit 857059
#include "ib_smi.h"
Packit 857059
#include "ib_gsi.h"
Packit 857059
#include "ib_ibt.h"
Packit 857059
#include "ib_generalServices.h"
Packit 857059
#include "gsadebug.h"
Packit 857059
#include "vca_export.h"
Packit 857059
#include "statustext.h"
Packit 857059
#include "ibyteswap.h"
Packit 857059
#include "ispinlock.h"
Packit 857059
#include "isyscallback.h"
Packit 857059
#include "ilist.h"
Packit 857059
#include "itimer.h"
Packit 857059
#include "imath.h"
Packit 857059
#include "isyscallback.h"
Packit 857059
#include "smagsa.h"
Packit 857059
#include "gsi_params.h"
Packit 857059
Packit 857059
#if defined (__cplusplus)
Packit 857059
extern "C" {
Packit 857059
#endif
Packit 857059
Packit 857059
Packit 857059
Packit 857059
//
Packit 857059
// Definitions
Packit 857059
//
Packit 857059
Packit 857059
#define	MAX_CLIENT_ID						0xff
Packit 857059
Packit 857059
#define GSA_RECVQ_LOW_WATER					50	// when to grow GlobalRecvQ Pool
Packit 857059
Packit 857059
#if defined(DBG) || defined(IB_DEBUG)
Packit 857059
Packit 857059
#define	GSA_CLASS_SIG						0x73616c63		// 'salc'
Packit 857059
#define	GSA_DGRM_SIG						0x6d726764		// 'mrgd'
Packit 857059
Packit 857059
#endif
Packit 857059
Packit 857059
Packit 857059
//
Packit 857059
// Structures
Packit 857059
//
Packit 857059
extern IBT_GLOBAL IbtGlobal;
Packit 857059
Packit 857059
Packit 857059
//
Packit 857059
// Structure to holds sends
Packit 857059
//
Packit 857059
typedef struct _GSA_POST_SEND_LIST {
Packit 857059
	uint32							DgrmIn;
Packit 857059
	ATOMIC_UINT						DgrmOut;
Packit 857059
	IBT_DGRM_ELEMENT				*DgrmList;
Packit 857059
	boolean							SARRequest;
Packit 857059
} GSA_POST_SEND_LIST;
Packit 857059
Packit 857059
Packit 857059
//
Packit 857059
// structure for memory pool
Packit 857059
//
Packit 857059
typedef struct _IBT_MEM_POOL {
Packit 857059
	struct _IBT_MEM_POOL			*Next;			// link to Growable Pool
Packit 857059
	struct _IBT_MEM_POOL			*Parent;		// our parent Growable Pool
Packit 857059
	SYS_CALLBACK_ITEM				*CallbackItem;	// used for Growable Pools
Packit 857059
	ATOMIC_UINT						GrowScheduled;	// used for Growable Pools
Packit 857059
	
Packit 857059
	SPIN_LOCK						Lock;			// lock
Packit 857059
	uint32							TotalElements;	// No. of elements in pool
Packit 857059
	uint32							Elements;		// Available for Gets
Packit 857059
	IBT_DGRM_ELEMENT				*DgrmList;		// datagram list
Packit 857059
	uint32							BuffersPerElement;
Packit 857059
	uint8							ReceivePool:1;	// Send or receive pool
Packit 857059
													// default FALSE: 
Packit 857059
													// SENDPool-Client buffer
Packit 857059
	uint8							Growable:1;		// head of growable pool
Packit 857059
	GLOBAL_MEM_LIST					*MemList;		// global memlist;
Packit 857059
	void							*UdBlock;		// registered mem block
Packit 857059
	void							*HeaderBlock;	// header block
Packit 857059
	IB_HANDLE						ServiceHandle;	// user's handle
Packit 857059
Packit 857059
#if defined(DBG) || defined(IB_DEBUG)
Packit 857059
	uint32							SigInfo;
Packit 857059
#endif
Packit 857059
} IBT_MEM_POOL;
Packit 857059
Packit 857059
Packit 857059
typedef struct _IBT_DGRM_ELEMENT_PRIV {
Packit 857059
	IBT_DGRM_ELEMENT				DgrmElement;
Packit 857059
	IBT_MEM_POOL					*MemPoolHandle;
Packit 857059
	// TBD - replace this with a Union { pPostSendList; IsSarRecv }
Packit 857059
	GSA_POST_SEND_LIST				*Base;			// used for sends and recvs
Packit 857059
													// Sends: base to chain of
Packit 857059
													// multiple sends
Packit 857059
													// Recvs: Indicates SAR data
Packit 857059
	GSA_POST_SEND_LIST				PostSendList;	// The actual list
Packit 857059
	uint64							SavedSendTid;	// User's TID on a send.
Packit 857059
	IB_HANDLE						AvHandle;		// AV Handle
Packit 857059
	IB_LOCAL_DATASEGMENT			*DsList;		// list to Data segments
Packit 857059
	struct	_GSA_SAR_CONTEXT		*pSarContext;	// Pointer to context data 
Packit 857059
													// for SAR
Packit 857059
} IBT_DGRM_ELEMENT_PRIV;
Packit 857059
Packit 857059
Packit 857059
Packit 857059
//
Packit 857059
//   GSA_GLOBAL_INFO
Packit 857059
//
Packit 857059
//	This structure is used to keep track of global information and tie the 
Packit 857059
//	various lists maintained into meaningful related entities. There is only 
Packit 857059
//	one instance of this structure per the whole of GSA activeCAlist is used 
Packit 857059
//	to link the list of all CA's in the system. Every time a CA is added, a 
Packit 857059
//	new CA structure is created and linked to the end of this field in a 
Packit 857059
//	LIFO fashion.
Packit 857059
//
Packit 857059
//	calock is used to guard access to the above list ( activeCAlist ).
Packit 857059
//
Packit 857059
//	ServiceClassList is used to link the list of all registered service 
Packit 857059
//	classes. Every time a unique service class is registered, a service class 
Packit 857059
//	registration record ( GSA_SERVICE_CLASS_INFO ) is created and linked to
Packit 857059
//	this list in a LIFO fashion.
Packit 857059
//
Packit 857059
//	ServiceClassListLock is used to guard access to the list of service 
Packit 857059
//	classes ( ServiceClassList ).
Packit 857059
//
Packit 857059
//	The interfaces of GSA MUST check this state before providing any 
Packit 857059
//	useful functionality.
Packit 857059
//	if FALSE, GSA services are not available.
Packit 857059
//
Packit 857059
//	ConfigParam contains the list of configuration parameters used to configure 
Packit 857059
//	GSA. These values might be read from registry or from local configuration 
Packit 857059
//	file(s) , depending on the platform we are running on.
Packit 857059
//
Packit 857059
//
Packit 857059
typedef struct _GSA_GLOBAL_INFO
Packit 857059
{
Packit 857059
	//
Packit 857059
	// this keeps track of internally generated client ids. Normally, a client id 
Packit 857059
	// is an 8-bit value that is unique across a single management class. 
Packit 857059
	// For now, this is unique across all management classes.
Packit 857059
	//
Packit 857059
	// ????TOBEDONE. 
Packit 857059
	// Later, when we have more management classes , this needs to be
Packit 857059
	// changed so that they are unique across just one management class
Packit 857059
	//
Packit 857059
Packit 857059
	uint8							ClientId;
Packit 857059
Packit 857059
Packit 857059
	SPIN_LOCK						CaListLock;
Packit 857059
    SMA_OBJECT						SmObj;
Packit 857059
Packit 857059
	IB_HANDLE						DgrmPoolRecvQ;
Packit 857059
    
Packit 857059
    SPIN_LOCK						ServiceClassListLock;
Packit 857059
    QUICK_LIST						ServiceClassList;
Packit 857059
Packit 857059
	// SAR Info
Packit 857059
    SPIN_LOCK						SARSendListLock;
Packit 857059
	QUICK_LIST						SARSendList;
Packit 857059
    SPIN_LOCK						SARRecvListLock;
Packit 857059
	QUICK_LIST						SARRecvList;
Packit 857059
	ATOMIC_UINT						SARRecvDropped;
Packit 857059
Packit 857059
	//IB_HANDLE						NotifyHandle;	// Notification calls
Packit 857059
Packit 857059
	uint8							ClientIdArray[MAX_CLIENT_ID];
Packit 857059
} GSA_GLOBAL_INFO;
Packit 857059
Packit 857059
Packit 857059
Packit 857059
//
Packit 857059
// extern declaration for our global information structure
Packit 857059
//
Packit 857059
#ifndef g_GsaGlobalInfo
Packit 857059
extern GSA_GLOBAL_INFO *g_GsaGlobalInfo;
Packit 857059
#endif
Packit 857059
Packit 857059
//
Packit 857059
// GSA_SERVICE_CLASS_INFO
Packit 857059
//
Packit 857059
//
Packit 857059
//	This structure describes a registered service class . An instance of this 
Packit 857059
//	is created every time a unique service class is registered. 
Packit 857059
//
Packit 857059
//	ListItem is used to link this registration record into a list.
Packit 857059
//     
Packit 857059
//	Serviceclasssendlist is the head of all send buffers submitted by 
Packit 857059
//	the service class for sending. By definition these buffers are already 
Packit 857059
//	registered with one or more CAs.
Packit 857059
//
Packit 857059
//	serviceclassrecvlist is the head of all receive buffers submitted by 
Packit 857059
//	the service class for receiving. By definition, these buffers are 
Packit 857059
//	already registered with one or more CAs.
Packit 857059
//
Packit 857059
//	<MgmtClass, mgmtclassversion> describe the mgmt class and version 
Packit 857059
//	registered by the service class.
Packit 857059
//
Packit 857059
//	ServiceClassContext is the value supplied by the service class 
Packit 857059
//	during registration.
Packit 857059
//
Packit 857059
//	ReceiveCompletionCallback is the handler supplied by the service class 
Packit 857059
//	that is used to indicate receive completions on behalf of this service 
Packit 857059
//	class.
Packit 857059
//
Packit 857059
//	sendcompletehandler is the handler supplied by the service class used 
Packit 857059
//	to indicate send completions on behalf of this service class. 
Packit 857059
//
Packit 857059
//	Both ReceiveCompletionCallback and sendcompletehandler are 
Packit 857059
//	supplied by the service class and are used by GSA to indicate the 
Packit 857059
//	respective completion events.
Packit 857059
//
Packit 857059
//	MiscEventHandler is used to indicate miscellaneous events. This handler 
Packit 857059
//	is used to indicate the following events.
Packit 857059
//  CA being removed or disabled. In this case, the CA guid is provided 
Packit 857059
//	as input.
Packit 857059
//	A port being disconnected. In this case, the port GUID and the CA GUID 
Packit 857059
//	are provided as input.
Packit 857059
//	Other error events are also indicated. 
Packit 857059
//
Packit 857059
typedef struct _GSA_SERVICE_CLASS_INFO
Packit 857059
{
Packit 857059
	LIST_ITEM						ListItem;
Packit 857059
Packit 857059
	uint8							MgmtClass;
Packit 857059
	uint8							MgmtClassVersion;
Packit 857059
Packit 857059
	// Flags used to indicate responder, trap processor and report processor.
Packit 857059
	GSI_REGISTRATION_FLAGS			RegistrationFlags;
Packit 857059
Packit 857059
	boolean							bSARRequired;	// TRUE for SAR support
Packit 857059
Packit 857059
	void							*ServiceClassContext;
Packit 857059
	GSI_SEND_COMPLETION_CALLBACK	*SendCompletionCallback;
Packit 857059
	GSI_RECEIVE_CALLBACK			*ReceiveCompletionCallback;
Packit 857059
	
Packit 857059
	GSA_GLOBAL_INFO					*pGlobalInfo;
Packit 857059
Packit 857059
	uint8							ClientId;
Packit 857059
Packit 857059
#if defined(DBG) || defined(IB_DEBUG)
Packit 857059
	uint32							SigInfo;
Packit 857059
	ATOMIC_UINT						ErrorMsgs;
Packit 857059
#endif
Packit 857059
} GSA_SERVICE_CLASS_INFO;
Packit 857059
Packit 857059
//
Packit 857059
// Function declarations
Packit 857059
//
Packit 857059
FSTATUS
Packit 857059
GSALoad(
Packit 857059
	IN IBT_COMPONENT_INFO		*ComponentInfo
Packit 857059
	);
Packit 857059
Packit 857059
void
Packit 857059
GSAUnload(void);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
GsaAddDevice(
Packit 857059
	IN	EUI64					CaGuid,
Packit 857059
	OUT void					**Context
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
GsaRemoveDevice(
Packit 857059
	IN EUI64					CaGuid,
Packit 857059
	IN void						*Context
Packit 857059
	);
Packit 857059
Packit 857059
void
Packit 857059
GsaInitGlobalSettings(void);
Packit 857059
Packit 857059
void
Packit 857059
GsaOsComponentInfo(
Packit 857059
	IN IBT_COMPONENT_INFO		*ComponentInfo
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
PrepareCaForReceives(
Packit 857059
	IN	EUI64					CaGuid
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
GetCaContextFromAvInfo(
Packit 857059
	IN	IB_ADDRESS_VECTOR		*AvInfo,
Packit 857059
	IN	uint32					CaMemIndex,
Packit 857059
	OUT	IB_HANDLE				*AvHandle,
Packit 857059
	OUT	IB_HANDLE				*Qp1Handle,
Packit 857059
	OUT	IB_HANDLE				*Cq1Handle,
Packit 857059
	OUT SPIN_LOCK				**QpLock,
Packit 857059
	OUT	IB_L_KEY				*LKey
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
GetGsiContextFromPortGuid(
Packit 857059
	IN	EUI64					PortGuid,
Packit 857059
	OUT	IB_HANDLE				*Qp1Handle,
Packit 857059
	OUT	uint8					*PortNumber
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
CreateDgrmPool(
Packit 857059
	IN	IB_HANDLE				ServiceHandle,
Packit 857059
	IN	uint32					ElementCount,
Packit 857059
	IN	uint32                  BuffersPerElement,
Packit 857059
	IN	uint32					BufferSizeArray[],
Packit 857059
	IN	uint32                  ContextSize,
Packit 857059
	OUT IB_HANDLE				*DgrmPoolHandle
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
DestroyDgrmPool(
Packit 857059
	IN	IB_HANDLE				DgrmPoolHandle
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
DgrmPoolGet(
Packit 857059
	IN	IB_HANDLE				DgrmPoolHandle,
Packit 857059
	IN OUT	uint32				*ElementCount,
Packit 857059
	OUT	IBT_DGRM_ELEMENT		**DgrmList
Packit 857059
	);
Packit 857059
Packit 857059
void
Packit 857059
DumpDgrmElement(
Packit 857059
	IN IBT_DGRM_ELEMENT		*DgrmElement
Packit 857059
	);
Packit 857059
Packit 857059
uint32
Packit 857059
DgrmPoolCount(
Packit 857059
	IN	IB_HANDLE				DgrmPoolHandle
Packit 857059
	);
Packit 857059
Packit 857059
uint32
Packit 857059
DgrmPoolTotal(
Packit 857059
	IN	IB_HANDLE				DgrmPoolHandle
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
DgrmPoolPut(
Packit 857059
	IN	IBT_DGRM_ELEMENT		*pDgrmList
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
CreateGrowableDgrmPool(
Packit 857059
	IN	IB_HANDLE				ServiceHandle,
Packit 857059
	IN	uint32					ElementCount,
Packit 857059
	IN	uint32                  BuffersPerElement,
Packit 857059
	IN	uint32					BufferSizeArray[],
Packit 857059
	IN	uint32                  ContextSize,
Packit 857059
	OUT IB_HANDLE				*DgrmPoolHandle
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
DgrmPoolGrow(
Packit 857059
	IN	IB_HANDLE				DgrmPoolHandle,
Packit 857059
	IN	uint32					ElementCount
Packit 857059
	);
Packit 857059
Packit 857059
void
Packit 857059
DgrmPoolGrowAsNeeded(
Packit 857059
	IN	IB_HANDLE				DgrmPoolHandle,
Packit 857059
	IN	uint32					lowWater,
Packit 857059
	IN	uint32					maxElements,
Packit 857059
	IN	uint32					growIncrement
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
CreateGlobalRecvQ(void);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
DgrmPoolAddToGlobalRecvQ(
Packit 857059
	IN	uint32					ElementCount
Packit 857059
	);
Packit 857059
Packit 857059
void
Packit 857059
GrowRecvQAsNeeded(void);
Packit 857059
Packit 857059
void
Packit 857059
DestroyGlobalRecvQ(void);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
DecrementGsiRecvQPostedForPortGuid(
Packit 857059
	IN	EUI64					PortGuid,
Packit 857059
	OUT	uint32					*RecvQPosted
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
PostRecvMsgToPort(
Packit 857059
	IN	uint32					ElementCount,
Packit 857059
	IN	EUI64					PortGuid
Packit 857059
	);
Packit 857059
Packit 857059
void	
Packit 857059
GsaNotifyCallback(
Packit 857059
	IN	IB_NOTIFY_RECORD		NotifyRecord
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
GsaNotifyClients(
Packit 857059
	IN	uint8				ClientId,
Packit 857059
	IN	MAD_COMMON			*pMadHdr,
Packit 857059
	IN	IBT_DGRM_ELEMENT	*pDgrm );
Packit 857059
Packit 857059
// has this client requested GSI to do RMPP protocol handling for it
Packit 857059
boolean
Packit 857059
IsSarClient(
Packit 857059
	IN	uint8				ClientId,
Packit 857059
	IN	uint8				MgmtClass );
Packit 857059
Packit 857059
// RMPP entry points, provided by the RMPP protocol provider
Packit 857059
Packit 857059
// destroy all SAR Context data, used during Unload
Packit 857059
void
Packit 857059
DestroySARContexts(void);
Packit 857059
Packit 857059
// RMPP Sender - initiate a transfer which may require RMPP
Packit 857059
FSTATUS
Packit 857059
DoSARSend(
Packit 857059
	IN	GSA_SERVICE_CLASS_INFO	*ServiceClass, 
Packit 857059
	IN	GSA_POST_SEND_LIST		*PostList
Packit 857059
	);
Packit 857059
Packit 857059
// Common Completion Handlers for RMPP Sender and Receiver Contexts
Packit 857059
FSTATUS
Packit 857059
ProcessSARRecvCompletion (
Packit 857059
	IN	MAD						*pMad,
Packit 857059
	IN	IBT_DGRM_ELEMENT		**ppDgrm
Packit 857059
	);
Packit 857059
Packit 857059
void
Packit 857059
ProcessSARSendCompletion (
Packit 857059
	IN	MAD						*pMad,
Packit 857059
	IN	IBT_DGRM_ELEMENT		*pDgrm
Packit 857059
	);
Packit 857059
Packit 857059
FSTATUS
Packit 857059
GsiDoSendDgrm(
Packit 857059
	GSA_SERVICE_CLASS_INFO		*ServiceClass,
Packit 857059
	IN	GSA_POST_SEND_LIST		*pPostList
Packit 857059
	);
Packit 857059
Packit 857059
void GsiSendInvalid(
Packit 857059
	IN	IBT_DGRM_ELEMENT		*pDgrm
Packit 857059
	);
Packit 857059
Packit 857059
#if defined (__cplusplus)
Packit 857059
};
Packit 857059
#endif
Packit 857059
Packit 857059
Packit 857059
#endif	// _IBA_IB_GSA_MAIN_H_