00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _VLIB_AUX_H_
00019 #define _VLIB_AUX_H_
00020
00025 #include "vlib.h"
00026
00027 #define VLIB_GROW_UNITS 8
00028 #define VLIB_GROW_PORTS 4
00029 #define VLIB_GROW_ADAPTERS 2
00030
00031 #ifdef min
00032 # undef min
00033 #endif
00034 #define min(a,b) (((a) < (b)) ? (a) : (b))
00035
00036
00037
00038
00039
00040 struct vlib_adapter *getAdapterByIndex(uint32_t);
00041 struct vlib_adapter *getAdapterByHandle(HBA_HANDLE, HBA_STATUS *);
00042 struct vlib_adapter *getAdapterByDevid(devid_t);
00043 struct vlib_port *getPortByIndex(const struct vlib_adapter *, const uint32_t);
00044 struct vlib_port *getPortByWWPN(const struct vlib_adapter *, const wwn_t);
00045 struct vlib_unit *getUnitByIndex(const struct vlib_port *, const uint32_t);
00046 struct vlib_unit *getUnitByFcLun(const struct vlib_port *, uint64_t);
00047
00048 int addAdapterToRepos(struct vlib_adapter *);
00049 int addPortToRepos(struct vlib_adapter *, struct vlib_port *);
00050 int addUnitToRepos(struct vlib_port *, struct vlib_unit *);
00051
00052 HBA_STATUS getAdapterConfig(void);
00053 int getUnitsFromPort(struct vlib_port *);
00054
00055 int findIndexByName(char *);
00056 HBA_HANDLE openAdapterByIndex(HBA_UINT32);
00057 char* getSgDevFromPort(struct vlib_port *);
00058 char* getAttachedWLUN(struct vlib_adapter *, struct vlib_port *);
00059 void detachWLUN(struct vlib_adapter *, struct vlib_port *);
00060
00061 int revalidateAdapters(void);
00062 int updateAdapter(struct vlib_adapter *adapter);
00063 void doCloseAdapter(struct vlib_adapter *);
00064 void closeAllAdapters(void);
00065
00066 HBA_STATUS vlibErrnoToHBAStatus(const char *, int , int);
00067 HBA_STATUS vlibEvaluateScsiStatus(int, void *);
00068 HBA_PORTTYPE vlibCharToIntPortType(char *);
00069 HBA_PORTSTATE vlibCharToIntPortState(char *);
00070 HBA_PORTSPEED vlibCharToIntPortSpeed(char *);
00071 HBA_COS vlibCharToIntCOS(char *);
00072
00073
00074
00075
00076
00082 static inline void vlib_wwn_to_HBA_WWN(uint64_t wwn, HBA_WWN *hba)
00083 {
00084 *((uint64_t*)(&hba->wwn)) = wwn;
00085 }
00086
00092 static inline void vlib_HBA_WWN_to_wwn(HBA_WWN *hba, uint64_t *wwn)
00093 {
00094 *wwn = *((uint64_t*)hba->wwn);
00095 }
00096
00102 static inline uint32_t vlib_FCID_to_hbaFCID(uint32_t fcid)
00103 {
00104 return (fcid << 8);
00105 }
00106
00112 static inline uint32_t vlib_hbaFCID_to_FCID(uint32_t fcid)
00113 {
00114 return (fcid >> 8);
00115 }
00116
00117
00123 static inline void invalidateAllAdapters(void)
00124 {
00125 unsigned int i;
00126 struct vlib_adapter *adapter;
00127
00128 adapter = getAdapterByIndex(0);
00129 for (i = 0; i < vlib_data.adapters.used; ++i, ++adapter) {
00130 adapter->isInvalid = 1;
00131 }
00132 }
00133
00140 static inline void markRepositoryInvalid(void)
00141 {
00142 VLIB_MUTEX_LOCK(&vlib_data.mutex);
00143
00144 vlib_data.isValid = 0;
00145
00146 VLIB_MUTEX_UNLOCK(&vlib_data.mutex);
00147 }
00148
00149 #endif