/********************************************************
**
*   ibvsmad.h
*
*   header file for the ibvsmad library.
*   this library provides vendor specific mad capabilities.
*  
*   mread64, mwrite64 - IS3 I2C bus access MAD - ExtPortAccess -> I2C compliant port #1
*   mread4 , mwrite4  - IS3 CR-Space access MAD - ConfigSpaceAccess 
*
*   The interface is similar to the mtcr library interface in order to be able
*   to link with mst tools (spark).
*
*   author: yoniy@mellanox.co.il , Apr. 16th 2007
*/



#ifdef __cplusplus
#define EXTERN_C_START extern "C" {
#define EXTERN_C_END   }
#else
#define EXTERN_C_START
#define EXTERN_C_END
#endif

EXTERN_C_START

extern int ibdebug;

/*
  for spark: these MST_BLABLA are dummies since mtcr is not linked together with 
  ibvsmad yet on spark build.
*/
#define MST_GAMLA 0x0A
#define MST_CALBR 1
#define MST_USB   2
#define MST_USB_DIMAX 3
#define MST_IB 4
#define MST_IF 5 
#define MST_PPC 6
#define MST_PCI 7
#define MST_PCICONF 8
#define MST_TAVOR 0x09
#define ACCSES_VIA_IBVSMAD 0xBABE


struct __ibvsmad_hndl_t
{
    ib_portid_t portid;
    int sock;
    int tp;
    int i2c_slave;
};

typedef struct __ibvsmad_hndl_t mfile;




/********************************************************
**
*    Get handle for a specific IS3 lid
*
*/
mfile*
mopend(const char *lid, int for_mst_interface);




/********************************************************
**
*    Close, free handle
*
*/
int
mclose(mfile *h);




/********************************************************
**
*    Read a data block from an I2C slave on the IS3 bus using 
*    a vendor specific MAD sent to the IS3. 
*
*/
int
mread64(mfile *h, u_int32_t memory_address, u_int8_t *data, u_int32_t size);





/********************************************************
**
*    Read a data block from an I2C slave on the IS3 bus using 
*    a vendor specific MAD sent to the IS3
*
*/
int
mwrite64(mfile *h, u_int32_t memory_address, u_int8_t *data, u_int32_t size);





/********************************************************
**
*    Read a data block from an I2C slave on the IS3 bus using 
*    a vendor specific MAD sent to the IS3
*
*/
int
mread4(mfile *h, u_int32_t memory_address, u_int32_t *data);





/********************************************************
**
*    Write a data block to an I2C slave on the IS3 bus using 
*    a vendor specific MAD sent to the IS3
*
*/
int
mwrite4(mfile *h, u_int32_t memory_address, u_int32_t data);





/********************************************************
**
*    For compatibility with mtcr, made for spark
*
*/
void
mset_i2c_slave(mfile *h, u_int8_t is3_slave_addr);


EXTERN_C_END

