Blame IbAccess/Common/Inc/ib_dm.h

Packit 857059
/* BEGIN_ICS_COPYRIGHT3 ****************************************
Packit 857059
Packit 857059
Copyright (c) 2015, 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_COPYRIGHT3   ****************************************/
Packit 857059
Packit 857059
/* [ICS VERSION STRING: unknown] */
Packit 857059
Packit 857059
#ifndef _IBA_IB_DM_H_
Packit 857059
#define _IBA_IB_DM_H_ (1) /* suppress duplicate loading of this file */
Packit 857059
Packit 857059
#include "iba/public/datatypes.h"				/* Portable datatypes */
Packit 857059
#include "iba/public/ibyteswap.h"
Packit 857059
#include "iba/ib_generalServices.h"
Packit 857059
Packit 857059
#ifdef __cplusplus
Packit 857059
extern "C" {
Packit 857059
#endif
Packit 857059
Packit 857059
/* --------------------------------------------------------------------------
Packit 857059
 * IBTA Device Management Class
Packit 857059
 * --------------------------------------------------------------------------
Packit 857059
 */
Packit 857059
Packit 857059
/* Device Management methods */
Packit 857059
#define	DEVMGT_GET				MMTHD_GET
Packit 857059
#define	DEVMGT_SET				MMTHD_SET
Packit 857059
#define	DEVMGT_GET_RESP			MMTHD_GET_RESP
Packit 857059
#define	DEVMGT_TRAP				MMTHD_TRAP
Packit 857059
#define	DEVMGT_TRAP_REPRESS		MMTHD_TRAP_REPRESS
Packit 857059
#define DEVMGT_REPORT			MMTHD_REPORT
Packit 857059
#define DEVMGT_REPORT_RESP		MMTHD_REPORT_RESP
Packit 857059
Packit 857059
Packit 857059
/* Device Management Attributes IDs */		 	/* Attribute Modifier values */
Packit 857059
#define	DM_ATTRIB_ID_CLASS_PORTINFO		0x0001	/* 0x0000_0000 */
Packit 857059
#define	DM_ATTRIB_ID_NOTICE				0x0002	/* 0x0000_0000 - 0xFFFF_FFFF */
Packit 857059
#define	DM_ATTRIB_ID_IOUNIT_INFO		0x0010	/* 0x0000_0000 */
Packit 857059
#define	DM_ATTRIB_ID_IOCONTROLLER_PROFILE 0x0011/* 0x0000_0001 - 0x0000_00FF */
Packit 857059
										/*		(IOC slot#) */
Packit 857059
#define	DM_ATTRIB_ID_SERVICE_ENTRIES	0x0012	/* 0x0001_0000 - 0x00FF_FFFF */
Packit 857059
#define	DM_ATTRIB_ID_DIAGNOSTIC_TIMEOUT	0x0020	/* 0x0000_0001 - 0xFFFF_FFFF */
Packit 857059
										/*		(time unit in millisec) */
Packit 857059
#define	DM_ATTRIB_ID_PREPARE_TO_TEST	0x0021	/* 0x0000_0001 - 0xFFFF_FFFF */
Packit 857059
#define	DM_ATTRIB_ID_TEST_DEVICE_ONCE	0x0022	/* 0x0000_0001 - 0xFFFF_FFFF */
Packit 857059
#define	DM_ATTRIB_ID_TEST_DEVICE_LOOP	0x0023	/* 0x0000_0001 - 0xFFFF_FFFF */
Packit 857059
#define	DM_ATTRIB_ID_DIAG_CODE			0x0024	/* 0x0000_0001 - 0xFFFF_FFFF */
Packit 857059
/*		Reserved 0x0025 - 0xFEFF */
Packit 857059
/*		Vendor Specific	0xFF00-0xFFFF */
Packit 857059
#define	DM_ATTRIB_ID_VENDOR_MASK		0xff00	/* Vendor Specific Attrib IDs */
Packit 857059
Packit 857059
/* DM Class Specific MAD_STATUS (AsReg16) */
Packit 857059
#define MAD_STATUS_DM_IOC_NOT_RESPONDING	0x0100
Packit 857059
#define MAD_STATUS_DM_IOC_NO_SERVICE_ENTRIES	0x0200
Packit 857059
	/* bits 10-14 reserved */
Packit 857059
#define MAD_STATUS_DM_IOC_GENERAL_FAILURE	0x8000
Packit 857059
Packit 857059
/* A series of 4-bit nibbles with each representing an IOC slot in the IOU.
Packit 857059
 * Each 4-bit nibble can take the following values.  0x2-0xE are reserved.
Packit 857059
 */
Packit 857059
#define IOC_NOT_INSTALLED	0x0
Packit 857059
#define	IOC_INSTALLED		0x1
Packit 857059
/* reserved values for		0x02-0xE */
Packit 857059
#define	SLOT_NOT_EXISTED	0xF
Packit 857059
Packit 857059
/* The ControllerList nibble lists defined in IBA DM spec
Packit 857059
 *	The high nibble has lower controller slot #
Packit 857059
 *
Packit 857059
 *	(start of 1024bits)	 0xXX XX XX XX XX ...
Packit 857059
 *	slot #				   01 23 45 67 89 ...
Packit 857059
 */
Packit 857059
Packit 857059
#define	SLOT_INFO(clVal,slot)	(((slot)-1)%2 ? ((clVal) & 0x0F) : \
Packit 857059
											(((clVal) & 0xF0) >> 4))
Packit 857059
/* This macro gives the nibble of the specified IOC # */
Packit 857059
#define IOC_AT_SLOT(pIOUnitInfo,slot)		\
Packit 857059
		SLOT_INFO( (pIOUnitInfo)->ControllerList[((slot)-1)/2], slot)
Packit 857059
Packit 857059
#define IOC_AT_SLOT_IS_PRESENT(pIOUnitInfo, slot) \
Packit 857059
		(IOC_AT_SLOT(pIOUnitInfo, slot) == IOC_INSTALLED)
Packit 857059
Packit 857059
Packit 857059
#define SET_IOC_AT_SLOT(pIOUnitInfo, slot, value) \
Packit 857059
		((pIOUnitInfo)->ControllerList[((slot)-1)/2] = (((slot)-1)%2 ? \
Packit 857059
			(((pIOUnitInfo)->ControllerList[((slot)-1)/2] & 0xF0) \
Packit 857059
			 		| ((value) & 0xF)) \
Packit 857059
			: (((pIOUnitInfo)->ControllerList[((slot)-1)/2] & 0x0F) \
Packit 857059
					| ((value) << 4))))
Packit 857059
Packit 857059
Packit 857059
/* --------------------------------------------------------------------------
Packit 857059
 * DM Attribute Specific Data
Packit 857059
 * Declared in wire format
Packit 857059
 */
Packit 857059
#include "iba/public/ipackon.h"
Packit 857059
Packit 857059
/* There is one IOUnitInfo per CA */
Packit 857059
typedef struct __IOUnitInfo {
Packit 857059
	uint16		Change_ID;			/* monotonically incremented with rollover */
Packit 857059
									/*		by any change to ControllerList */
Packit 857059
	uint8		MaxControllers;		/* # of slots in Controller List */
Packit 857059
Packit 857059
#if	CPU_BE
Packit 857059
	uint8		Resv		:6;
Packit 857059
	uint8		DiagDeviceId:1;		/* attr modifier in diag attrs is IOC Slot */
Packit 857059
	uint8		OptionRom	:1;		/* 1 = present, 0 = absent */
Packit 857059
Packit 857059
#else			/* CPU_LE */
Packit 857059
	uint8		OptionRom	:1;		/* 1 = present, 0 = absent */
Packit 857059
	uint8		DiagDeviceId:1;		/* attr modifier in diag attrs is IOC Slot */
Packit 857059
	uint8		Resv		:6;
Packit 857059
#endif
Packit 857059
Packit 857059
	uint8		ControllerList[128];
Packit 857059
} PACK_SUFFIX IOUnitInfo, *PIOUnitInfo;
Packit 857059
Packit 857059
Packit 857059
/* There can be up to 255 IOCs per IOU.  IOCs are identified by a 1 based
Packit 857059
 * slot number (1-255)
Packit 857059
 */
Packit 857059
#define DM_MAX_CONTROLLERS 255
Packit 857059
#define IOC_IDSTRING_SIZE 64
Packit 857059
typedef struct __IO_CONTROLLER_PROFILE {
Packit 857059
	uint64		IocGUID;				/* USE EUI-64 GUID */
Packit 857059
Packit 857059
	union {
Packit 857059
		uint32	AsUint32;
Packit 857059
		struct {
Packit 857059
Packit 857059
#if	CPU_BE
Packit 857059
			uint32		VendorId		:24;/* IO Controller vendor, IEEE */
Packit 857059
			uint32		Resv1			:8;
Packit 857059
#else	/* CPU_LE */
Packit 857059
			uint32		Resv1			:8;
Packit 857059
			uint32		VendorId		:24;/* IO Controller vendor, IEEE */
Packit 857059
#endif
Packit 857059
Packit 857059
		} v;
Packit 857059
	} ven;
Packit 857059
Packit 857059
#define	IocProfile_VendorId ven.v.VendorId
Packit 857059
Packit 857059
	uint32		DeviceId;				/* a number assigned by the vendor */
Packit 857059
										/* It can be used by an OS to select */
Packit 857059
										/* a device driver. */
Packit 857059
	uint16		DeviceVersion;		    /* device version assigned by vendor */
Packit 857059
	uint16		Resv2;
Packit 857059
Packit 857059
	union {
Packit 857059
		uint32	AsUint32;
Packit 857059
		struct {
Packit 857059
Packit 857059
#if	CPU_BE
Packit 857059
			uint32	SubSystemVendorID	:24;/* ID of the enclosure vendor, per IEEE */
Packit 857059
			uint32	Resv				:8;
Packit 857059
#else		/*CPU_LE */
Packit 857059
			uint32	Resv				:8;
Packit 857059
			uint32	SubSystemVendorID	:24;/* ID of the enclosure vendor, per IEEE			 */
Packit 857059
#endif
Packit 857059
Packit 857059
		} s;
Packit 857059
	} sub;
Packit 857059
Packit 857059
#define	IocProfile_SubSystemVendorID	sub.s.SubSystemVendorID
Packit 857059
Packit 857059
	uint32		SubSystemID;			/* A number identifying the subsystem */
Packit 857059
										/* where the controller resides */
Packit 857059
Packit 857059
	uint16		IOClass;				/* 0x0000-0xFFFE = Reserved pending */
Packit 857059
										/* I/O class specification approval */
Packit 857059
										/* 0xFFFF = vendor specific */
Packit 857059
Packit 857059
	uint16		IOSubClass;				/* 0x0000-0xFFFE = Reserved pending */
Packit 857059
										/* I/O subclass specification approval */
Packit 857059
										/* 0xFFFF = vendor specific */
Packit 857059
										/* Must be 0xFFFF if IOClass = 0xFFFF */
Packit 857059
Packit 857059
	uint16		Protocol;				/* 0x0000-0xFFFE = Reserved pending */
Packit 857059
										/* I/O subclass specification approval */
Packit 857059
										/* 0xFFFF = vendor specific */
Packit 857059
										/* Must be 0xFFFF if IOClass = 0xFFFF */
Packit 857059
Packit 857059
	uint16		ProtocolVer;			/* Protocol specific */
Packit 857059
	
Packit 857059
	uint16		Resv5;
Packit 857059
	uint16		Resv6;
Packit 857059
Packit 857059
	uint16		SendMsgDepth;			/* Max depth of the send message */
Packit 857059
										/* queue */
Packit 857059
Packit 857059
	uint8		Resv7;					/* RDMAReadDepth was 16 bits in 1.0a */
Packit 857059
	uint8		RDMAReadDepth;			/* Max depth of the per-channel RDMA */
Packit 857059
										/* read queue */
Packit 857059
Packit 857059
	uint32		SendMsgSize;			/* Max size of send messages in bytes */
Packit 857059
	
Packit 857059
	uint32		RDMASize;				/* Max size of outbound RDMA transfers */
Packit 857059
										/* initiated by this IOC (in bytes) */
Packit 857059
Packit 857059
	union {
Packit 857059
		uint8		CntlCapMask;
Packit 857059
		struct	{
Packit 857059
Packit 857059
#if	CPU_BE
Packit 857059
			uint8	AF		:1;			/*bit 7:Atomic Operations from IOCs */
Packit 857059
			uint8	AT		:1;			/*		Atomic Operations to IOCs */
Packit 857059
			uint8	WF		:1;			/*		RDMA Write Requests from IOCs */
Packit 857059
			uint8	WT		:1;			/*		RDMA Write Requests to IOCs */
Packit 857059
			uint8	RF		:1;			/*		RDMA Read Requests from IOCs */
Packit 857059
			uint8	RT		:1;			/*		RDMA Read Requests to IOCs */
Packit 857059
			uint8	SF		:1;			/*		Send Messages from IOCs */
Packit 857059
			uint8	ST		:1;			/*bit 0:Send Messages to IOCs */
Packit 857059
Packit 857059
#else		/* CPU_LE */
Packit 857059
			uint8	ST		:1;			/*bit 0:Send Messages to IOCs */
Packit 857059
			uint8	SF		:1;			/*		Send Messages from IOCs */
Packit 857059
			uint8	RT		:1;			/*		RDMA Read Requests to IOCs */
Packit 857059
			uint8	RF		:1;			/*		RDMA Read Requests from IOCs */
Packit 857059
			uint8	WT		:1;			/*		RDMA Write Requests to IOCs */
Packit 857059
			uint8	WF		:1;			/*		RDMA Write Requests from IOCs */
Packit 857059
			uint8	AT		:1;			/*		Atomic Operations to IOCs */
Packit 857059
			uint8	AF		:1;			/*bit 7:Atomic Operations from IOCs */
Packit 857059
#endif
Packit 857059
Packit 857059
		} ctlrCapMask;
Packit 857059
	} ccm;
Packit 857059
Packit 857059
	uint8	Resv8;
Packit 857059
	uint8		ServiceEntries;			/* Number of entries in the ServiceEntries table */
Packit 857059
	uint8		Resv4[9];
Packit 857059
	uint8		IDString[IOC_IDSTRING_SIZE];/* ASCII text string for identifying the */
Packit 857059
										/* controller to operator */
Packit 857059
} PACK_SUFFIX IOC_PROFILE, *PIOC_PROFILE;
Packit 857059
Packit 857059
Packit 857059
/* there can be up to 255 service entries per IOC.
Packit 857059
 * Services are identified by a 0 based service number 0-254
Packit 857059
 * Note the IBTA spec is not clear if the 1st service is 0 or 1.  At present
Packit 857059
 * all devices from SilverStorm, Mellanox and Engenio use 0 as the 1st service
Packit 857059
 */
Packit 857059
Packit 857059
/* create attribute modifier for DM_ATTRIB_ID_SERVICE_ENTRIES to select
Packit 857059
 * a range of service entries within an IOC (1 based IOC slot number)
Packit 857059
 */
Packit 857059
#define DM_ATTRIB_MODIFIER_SERVICE_ENTRIES(slot,first,last) \
Packit 857059
			(((slot) << 16) | (first) | ((last) << 8))
Packit 857059
Packit 857059
/* extract parts of attribute modifier for a SERVICE_ENTRIES Attribute */
Packit 857059
#define DM_ATTRIB_MODIFIER_SERVICE_ENTRIES_SLOT(modifier) \
Packit 857059
			(((modifier) >> 16) & 0xff)
Packit 857059
#define DM_ATTRIB_MODIFIER_SERVICE_ENTRIES_FIRST(modifier) \
Packit 857059
			((modifier) & 0xff)
Packit 857059
#define DM_ATTRIB_MODIFIER_SERVICE_ENTRIES_LAST(modifier) \
Packit 857059
			(((modifier) >> 8) & 0xff)
Packit 857059
Packit 857059
#define IOC_SERVICE_NAME_SIZE 40
Packit 857059
typedef struct __IOC_SERVICE {
Packit 857059
Packit 857059
	uchar		Name[IOC_SERVICE_NAME_SIZE];/* Service name string in text format */
Packit 857059
	uint64		Id;						/* An identifier of the associated Service */
Packit 857059
Packit 857059
} PACK_SUFFIX IOC_SERVICE, *PIOC_SERVICE;
Packit 857059
Packit 857059
typedef struct __IOC_SERVICE_ENTRIES {
Packit 857059
Packit 857059
	IOC_SERVICE	ServiceEntry[4];
Packit 857059
Packit 857059
} PACK_SUFFIX DM_IOC_SERVICE_ENTRIES, *PDM_IOC_SERVICE_ENTRIES;
Packit 857059
Packit 857059
Packit 857059
typedef struct __DIAGNOSTIC_TIMEOUT {
Packit 857059
	uint32		MaxDiagTime;			/* Max time to finish the diagnotic operation */
Packit 857059
										/* in milli-seconds */
Packit 857059
} PACK_SUFFIX DIAGNOSTIC_TIMEOUT, *PDIAGNOSTIC_TIMEOUT;
Packit 857059
Packit 857059
typedef enum {
Packit 857059
		DM_DIAG_CODE_OPERATIONAL = 0x0000
Packit 857059
		/* others are vendor specific */
Packit 857059
} DM_DIAG_CODE_VALUE;
Packit 857059
Packit 857059
typedef struct __DIAG_CODE {
Packit 857059
	uint16		DiagCode;			/* a DM_DIAG_CODE_VALUE */
Packit 857059
	/* additional vendor specific data permitted */
Packit 857059
} PACK_SUFFIX DIAG_CODE, *PDIAG_CODE;
Packit 857059
Packit 857059
/* End of packed data structures */
Packit 857059
#include "iba/public/ipackoff.h"
Packit 857059
Packit 857059
Packit 857059
/* -------------------------------------------------------------------------- */
Packit 857059
/* Byte swap between cpu and network formats */
Packit 857059
Packit 857059
static __inline void
Packit 857059
BSWAP_DM_IOUNIT_INFO (PIOUnitInfo pIOUnitInfo)
Packit 857059
{
Packit 857059
#if CPU_LE
Packit 857059
	pIOUnitInfo->Change_ID = ntoh16(pIOUnitInfo->Change_ID);
Packit 857059
#endif
Packit 857059
}
Packit 857059
Packit 857059
static __inline void
Packit 857059
BSWAP_DM_IOC_PROFILE (PIOC_PROFILE pIOC_PROFILE)
Packit 857059
{
Packit 857059
#if CPU_LE
Packit 857059
	pIOC_PROFILE->IocGUID		= ntoh64(pIOC_PROFILE->IocGUID);
Packit 857059
Packit 857059
	pIOC_PROFILE->ven.AsUint32	= ntoh32(pIOC_PROFILE->ven.AsUint32);
Packit 857059
	pIOC_PROFILE->DeviceId		= ntoh32(pIOC_PROFILE->DeviceId);
Packit 857059
	
Packit 857059
	pIOC_PROFILE->DeviceVersion	= ntoh16(pIOC_PROFILE->DeviceVersion);
Packit 857059
	/* 16-bit Resv 2: should be all 0. */
Packit 857059
	pIOC_PROFILE->sub.AsUint32	= ntoh32(pIOC_PROFILE->sub.AsUint32);
Packit 857059
	
Packit 857059
	pIOC_PROFILE->SubSystemID	= ntoh32(pIOC_PROFILE->SubSystemID);
Packit 857059
	pIOC_PROFILE->IOClass		= ntoh16(pIOC_PROFILE->IOClass);
Packit 857059
	pIOC_PROFILE->IOSubClass	= ntoh16(pIOC_PROFILE->IOSubClass);
Packit 857059
Packit 857059
	pIOC_PROFILE->Protocol		= ntoh16(pIOC_PROFILE->Protocol);
Packit 857059
	pIOC_PROFILE->ProtocolVer	= ntoh16(pIOC_PROFILE->ProtocolVer);
Packit 857059
	
Packit 857059
	pIOC_PROFILE->SendMsgDepth	= ntoh16(pIOC_PROFILE->SendMsgDepth);
Packit 857059
	pIOC_PROFILE->RDMAReadDepth	= ntoh16(pIOC_PROFILE->RDMAReadDepth);
Packit 857059
	pIOC_PROFILE->SendMsgSize	= ntoh32(pIOC_PROFILE->SendMsgSize);
Packit 857059
Packit 857059
	pIOC_PROFILE->RDMASize		= ntoh32(pIOC_PROFILE->RDMASize);
Packit 857059
#endif
Packit 857059
}
Packit 857059
Packit 857059
static __inline void
Packit 857059
BSWAP_DM_IOC_SERVICE (PIOC_SERVICE pIOC_SERVICE)
Packit 857059
{
Packit 857059
#if CPU_LE
Packit 857059
	pIOC_SERVICE->Id = ntoh64(pIOC_SERVICE->Id);
Packit 857059
#endif
Packit 857059
}
Packit 857059
Packit 857059
static __inline void
Packit 857059
BSWAP_DM_DIAGNOSTIC_TIMEOUT (PDIAGNOSTIC_TIMEOUT pDIAGNOSTIC_TIMEOUT)
Packit 857059
{
Packit 857059
#if CPU_LE
Packit 857059
	pDIAGNOSTIC_TIMEOUT->MaxDiagTime = 
Packit 857059
		ntoh32(pDIAGNOSTIC_TIMEOUT->MaxDiagTime);
Packit 857059
#endif
Packit 857059
}
Packit 857059
Packit 857059
static __inline void
Packit 857059
BSWAP_DM_DIAG_CODE (PDIAG_CODE pDIAG_CODE)
Packit 857059
{
Packit 857059
#if CPU_LE
Packit 857059
	pDIAG_CODE->DiagCode = ntoh16(pDIAG_CODE->DiagCode);
Packit 857059
#endif
Packit 857059
}
Packit 857059
Packit 857059
#ifdef __cplusplus
Packit 857059
}
Packit 857059
#endif
Packit 857059
Packit 857059
#endif /* _IBA_IB_DM_H_ */